Can't use output.manualChunks during Nuxt build
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 285
- Forks
- 33
- Avg merge
- 22h 38m
- Merged PRs (30d)
- 3
Description
Environment
- Operating System:
Linux - Node Version:
v16.13.1 - Nuxt Version:
2.16.0-27347055.777a4b7f - Package Manager:
npm@8.1.2 - Bundler:
Webpack - User Config:
components,bridge,vite,css,target,head,plugins,buildModules,stories,telemetry - Runtime Modules:
- - Build Modules:
@nuxt/bridge@3.0.0-27338323.1e98259
Reproduction
Attempt to specify manualChunks in nuxt.config:
vite: {
build: {
rollupOptions: {
output: {
inlineDynamicImports: false, // <-- I get manualChunks, but not all the ones I specify
manualChunks: {
utils: ['./lib/utils.js'] // example. utils will correctly be created in .nuxt/dist/server/chunks, but never transferred to .output/server/chunks
}
}
}
},
}
Describe the bug
When attempting to build Nuxt application which may work perfectly fine in development mode (nuxi dev), actually building the application using nuxi build will finally see and warn about chunk sizes being too large. This is the typical warning message that appears:
(!) Some chunks are larger than 500 KiB after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/guide/en/#outputmanualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
I have tried to use dynamic imports as much as possible, but this is not always ideal because then it requires so much code refactoring and lose the benefit of top-level imports. I'd also prefer not to increase the chunk size warning limit since the warning should probably not be ignored. So, I try specify manualChunks only to encounter the following error message:
Invalid value for option "output.manualChunks" - this option is not supported for "output.inlineDynamicImports".
It seems like I can't specify those options. It would be nice if I could.
Additional context
No response
Logs
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the vite.rollupOptions configuration in nuxt.config and reproduce the behavior with nuxi build, comparing it with nuxi dev. Trace the generated chunks from .nuxt/dist/server/chunks to .output/server/chunks; done means the requested manualChunks are transferred without the inlineDynamicImports conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nuxt, vite
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100