You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
run npm run build, then npm run preview, get {"items":[]}
Describe the bug
Nitro have injected a custom moduleSideEffects config, replace the default config true, makes all module are aggressive tree-shakeable (including workspace code and external packages)
This is a real problem. Nitro's custom moduleSideEffects config overrides Rolldown's default (which is true, meaning "treat all modules as having side effects"). With the override, Rolldown aggressively tree-shakes modules that register themselves through side effects.
This is especially bad with plugin-pattern libraries like Pothos where you import a plugin purely for its side effect of registering it with the builder:
import'@pothos/plugin-prisma';// this module's side effect registers the plugin// tree-shaking removes it because theres no explicit usage
Dev mode works (no tree-shaking), production build removes the import and breaks the feature.
Workaround: mark specific imports as side-effectful in your Nitro config:
The real fix should be on Nitro's side though. Overriding moduleSideEffects to false is too aggressive as a default. Either remove the override (let Rolldown use its default true) or only apply it to known-safe modules.
Activity
[-]`moduleSideEffects` defaults override Rolldown settings, causing aggressive tree-shaking[/-][+]Nitro's `moduleSideEffects` defaults override Rolldown settings, causing aggressive tree-shaking[/+]idirdev commentedon Mar 11, 2026
This is a real problem. Nitro's custom moduleSideEffects config overrides Rolldown's default (which is true, meaning "treat all modules as having side effects"). With the override, Rolldown aggressively tree-shakes modules that register themselves through side effects.
This is especially bad with plugin-pattern libraries like Pothos where you import a plugin purely for its side effect of registering it with the builder:
Dev mode works (no tree-shaking), production build removes the import and breaks the feature.
Workaround: mark specific imports as side-effectful in your Nitro config:
The real fix should be on Nitro's side though. Overriding moduleSideEffects to false is too aggressive as a default. Either remove the override (let Rolldown use its default true) or only apply it to known-safe modules.
fix(build): stop aggressive tree-shaking of side-effect imports