-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
Environment
- Operating System: Darwin
- Node Version: v22.16.0
- Nuxt Version: 4.2.1
- CLI Version: 3.30.0
- Nitro Version: 2.12.9
- Package Manager: pnpm@10.22.0
- Builder: -
- User Config: extends
- Runtime Modules: -
- Build Modules: -
Reproduction
https://github.com/dword-design/demo-nuxt-layers-wrong-outdir
pnpm install --frozen-lockfilepnpm build
Describe the bug
Expected: .output is generated in cwd.
Actual: .output is generated in foo subfolder.
This always happens when Jiti imports the layer using ESM instead of transpiling:
- When the layer config is a
.jsfile and"type": "module"is set inpackage.json - When the layer config is an
.mjsfile - When the layer is in
node_modules(which imho is a frequent case, including mine)
It works as expected when nuxt.config.ts is a TypeScript file.
I think the issue is that when importing using ESM, the ESM cache is there and there is probably some place where Nuxt is setting rootDir in an already-imported layer or sth. With transpiling, Jiti will always do a clean import.
Looks like the issue came in with nuxt@3.14.0. There Jiti@2 was introduced that adds native ESM imports. I guess that's where it came in, but I think the root cause is a mutated data issue in Nuxt.
Flo0806