T
TanStack9mo ago
national-gold

Dead code elimination

In the dev env for this server function the code in getPlayedWords is only getting executed if that following console.log is there. The only side effect in getPlayedWords is console logging for dev/debug purposes. Is the dead code elimination being too aggressive in this case or is this as expected?
export const submitMoveSF = createServerFn({ method: 'POST' })
.validator((data: { userGameId: number; tiles: TileModel[] }) => data)
.handler(async ({ data }) => {
. . .
const playedWords = getPlayedWords(userGame.game.board, data.tiles)
console.log(`playedWords: ${JSON.stringify(playedWords)}`)
export const submitMoveSF = createServerFn({ method: 'POST' })
.validator((data: { userGameId: number; tiles: TileModel[] }) => data)
.handler(async ({ data }) => {
. . .
const playedWords = getPlayedWords(userGame.game.board, data.tiles)
console.log(`playedWords: ${JSON.stringify(playedWords)}`)
2 Replies
national-gold
national-gold9mo ago
it might just be too aggressive here can you please open a github issue with an example so we can debug?
national-gold
national-goldOP9mo ago
GitHub
Dead code elimination possibly being too aggressive · Issue #3104 ·...
Which project does this relate to? Start Describe the bug In the dev env for this server function the code inisValidMove is only getting executed if the following console.log is there. The only sid...

Did you find this page helpful?