nuxt / nuxt/bridge

Can't use output.manualChunks during Nuxt build

Open
#50 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

🔨 p3-minor-bug nitro
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:

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.