-
Notifications
You must be signed in to change notification settings - Fork 710
Description
Reproduction link or steps
A quick background context, I've tried quite a bit to repro this in stackblitz/in a separate repro, but it seems like this only happens when my application is big enough to cause the chunking to happen, I may be missing some advanced chunking options to make this repro easier, but for now I'll list all my findings and at least a repro-able branch of my app in hopes that it will help
- Git clone repo https://github.com/Esposter/Esposter/tree/rolldown_build___commonJSMin_error_repro
- Run
pnpm iandpnpm build:packages
May need to enable git symlinks
- Cd
packages/app - Run
pnpm build - Observe in
packages/app/.output/server/chunks/build/server.mjsfile that you get an issue as __commonJSMin is called before it is defined. It seems to have calledvar require_shared_cjs_prod = __commonJSMin((exports)...before it is defined. Below is a way to look at a "correct" version.
I cannot confirm if the following comparison is "correct", but it seems fine and has not chunked the big part that causes the issue
To actually run the server you would need to follow the read me and install postgres db, but I've not included here as it may be too much effort for maintainer to repro, feel free to just grab the build output and close this issue if the nuxt build output has been checked
Comparisons
- To further compare, delete
packages/app/app/pages/anime.vuefile, which happens to be a good enough size that it doesn't cause the chunking and hoisting of calling __commonJSMin - Run
pnpm buildand observepackages/app/.output/server/chunks/build/server.mjsfile that __commonJSMin does seem to be defined before called now, without anymore chunking into../_/nitro.mjs. - This does not seem to be an issue anymore as __commonJSMin is properly defined before it is called, this may be a rolldown chunking issue
Extra Observations
- It seems like this is due to a csj/esm shared function with nuxt called
useFetchthat generates the __commonJSMin in theserver.mjsfile, this is hoisted wrongly, calling the __commonJSMin function before it is defined.
What is expected?
The application should build correct code that properly runs in nuxt.
What is actually happening?
The build seems successful, but does not produce correct runnable code.
System Info
System:
OS: Windows 10 10.0.19045
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 10.37 GB / 31.91 GB
Binaries:
Node: 24.1.0 - C:\Program Files\nodejs\node.EXE
npm: 11.3.0 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.12.1 - C:\Program Files\nodejs\pnpm.CMD
bun: 1.2.16 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Chromium (135.0.3179.73)
Internet Explorer: 11.0.19041.5794Any additional comments?
This is a bit of a weird issue I've been investigating for a while, will also cross-check with just using vite and see if there are any findings here. At first I thought may be an issue with nuxt/rolldown-vite, but seeing as how my app was working fine with normal vite, and the builds seem to be correct for a certain size until it starts chunking, I suspect it may be a rolldown issue.
May be from related issues:
#4738
#4617
but can't be sure