T
TanStack4mo ago
adverse-sapphire

getting rid of build warnings

How can i get rid of these?
No description
7 Replies
adverse-sapphire
adverse-sapphireOP4mo ago
Im using convex tanstack start project
metropolitan-bronze
metropolitan-bronze4mo ago
from what i know they dont really matter or affect the final build it's just that some things are imported but never used it shouldn't cause any issues
adverse-sapphire
adverse-sapphireOP4mo ago
but is there a way to silence them if they dont matter?
optimistic-gold
optimistic-gold3mo ago
GitHub
[Vite] Noisy error “Module level directives cause errors when bun...
Reproduction If I got more time, I may submit a PR with a failing test, but for now, here’s an issue. To reproduce: git clone https://github.com/dtinth/fewshot cd fewshot git checkout 82d6437be436f...
foreign-sapphire
foreign-sapphire3mo ago
At least in my case that didn't work - the warnings are coming during the nitro build step (my logs look the same as the OP screenshot) and setting build.rollupOptions.onWarn seems not to affect those If there's any way I'd love to get rid of these since they make my logs noisy and have been bothering me 😄
optimistic-gold
optimistic-gold3mo ago
I guess this will be soon possible to set the onWarn properly once we have decoupled nitro from start
adverse-sapphire
adverse-sapphireOP3mo ago
jup also didnt help me 🙁 okay i found a way but im still trying to debug smth #vite.config.ts
export default defineConfig({
server: {
port: 3000,
},
build: {
// Reduce console noise during build
// @todo: check if problem is fixed, same for nitro.config.ts
rollupOptions: {
onwarn(warning, warn) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
return
}
if (warning.code === 'SOURCEMAP_BROKEN' && warning.plugin === 'vite:css-post') {
return
}

// console.log('###', warning)
warn(warning)
},
},
},
plugins: [
.....
export default defineConfig({
server: {
port: 3000,
},
build: {
// Reduce console noise during build
// @todo: check if problem is fixed, same for nitro.config.ts
rollupOptions: {
onwarn(warning, warn) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
return
}
if (warning.code === 'SOURCEMAP_BROKEN' && warning.plugin === 'vite:css-post') {
return
}

// console.log('###', warning)
warn(warning)
},
},
},
plugins: [
.....
#nitro.config.ts
import { defineNitroConfig } from 'nitropack/config'

export default defineNitroConfig({
// Suppress build warnings
rollupConfig: {
onwarn(warning, warn) {
// Suppress \"use client\" module level directive warnings
if (
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
warning.message?.includes('"use client"')
) {
return
}
if (warning.code === 'CIRCULAR_DEPENDENCY' &&
['node_modules/nitropack'].some(term => warning.message?.includes(term))) {
return
}

// console.log('$$$', warning)
warn(warning)
}
},
})
import { defineNitroConfig } from 'nitropack/config'

export default defineNitroConfig({
// Suppress build warnings
rollupConfig: {
onwarn(warning, warn) {
// Suppress \"use client\" module level directive warnings
if (
warning.code === 'MODULE_LEVEL_DIRECTIVE' &&
warning.message?.includes('"use client"')
) {
return
}
if (warning.code === 'CIRCULAR_DEPENDENCY' &&
['node_modules/nitropack'].some(term => warning.message?.includes(term))) {
return
}

// console.log('$$$', warning)
warn(warning)
}
},
})

Did you find this page helpful?