Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails when passing manualchunks to rollup #1718

Closed
paul-schwendenman opened this issue Jun 20, 2021 · 9 comments · Fixed by #2702
Closed

Build fails when passing manualchunks to rollup #1718

paul-schwendenman opened this issue Jun 20, 2021 · 9 comments · Fixed by #2702

Comments

@paul-schwendenman
Copy link

Describe the bug
When passing manual chunks to rollup through vite, the build falls.

Logs
n/a see stack trace

To Reproduce

To recreate, I added:

		vite: {
			build: {
				rollupOptions: {
					output: {
						manualChunks: {
							lodash: ['lodash']
						}
					}
				}
			}
		}

to svelte.config.js in the hacker news example and I get the following error.

The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
> The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
Error: The "output.manualChunks" option is not supported for "output.inlineDynamicImports".

Note, I get the same error with different manualChunk configs. I also got an error in my project after installing the local build. I tried disabling inlineDynamicImports but that config is protected by sveltekit.

Expected behavior
The build should succeed. I suppose there should be a way to specify "output.inlineDynamicImports." If sveltekit is manually edited to disable inlineDynamicImports the build will pass:

I hacked my @sveltejs/kit locally to comment out // inlineDynamicImports: true and everything works as expected with a lodash chunk on the Sveltekit demo app

from comment by @johnnysprinkles

Stacktraces

Stack trace
The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
> The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
Error: The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
    at error (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:164:30)
    at getManualChunks (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:20695:20)
    at normalizeOutputOptions (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:20466:23)
    at getOutputOptions (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:20817:12)
    at getOutputOptionsAndPluginDriver (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:20812:12)
    at handleGenerateWrite (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:20789:74)
    at Object.write (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/node_modules/rollup/dist/shared/rollup.js:20756:20)
    at generate (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:45393:64)
    at doBuild (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:45406:26)
    at async Object.build (/home/paul/external/kit/node_modules/.pnpm/vite@2.3.7/node_modules/vite/dist/node/chunks/dep-bc228bbb.js:45230:16)

Information about your SvelteKit Installation:

Diagnostics

I am running a locally built version of the master branch so version 1.116(?) of sveltekit

$ npx envinfo --system --npmPackages svelte,@sveltejs/kit,@sveltejs/adapter-node,@sveltejs/adapter-static,@sveltejs/adapter-begin,@sveltejs/adapter-netlify,@sveltejs/adapter-vercel vite --binaries --browsers
npx: installed 1 in 0.977s

  System:
    OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 3.64 GB / 15.52 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.17.0 - ~/.asdf/installs/nodejs/14.17.0/bin/node
    npm: 6.14.13 - ~/.asdf/installs/nodejs/14.17.0/bin/npm
  Browsers:
    Firefox: 89.0.1
  npmPackages:
    @sveltejs/adapter-node: ^1.0.0-next.25 => 1.0.0-next.25 
    @sveltejs/adapter-static: ^1.0.0-next.11 => 1.0.0-next.11 
    @sveltejs/kit: ^1.0.0-next.115 => 1.0.0-next.115 
    svelte: ^3.38.0 => 3.38.2 

Severity
Low, I was just trying to change my build output by reshaping the vendor chunk. I am able to deploy without this change.

Additional context
related to:

@benmccann
Copy link
Member

This should be fixed now: #1572

@bhvngt
Copy link

bhvngt commented Jul 24, 2021

Hi @benmccann. Is the fix #1572 rolled out? I am using sveltejs/kit 1.0.0-next.136 and I am still facing this issue. Here's my vite config followed by the error log

		vite: {
			build: {
				chunkSizeWarningLimit: 1024,
				rollupOptions: {
					output: {
						inlineDynamicImports: false,
						manualChunks: {
							'framework7-core': ['framework7/lite'],
							'framework7-svelte': ['framework7-svelte']
						}
					}
				},
			}
		}
 build_server: The value for kit.vite.build.rollupOptions.output.inlineDynamicImports specified in svelte.config.js has been ignored. This option is controlled by SvelteKit.
vite v2.4.3 building SSR bundle for production...
✓ 237 modules transformed.
The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
> The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
Error: The "output.manualChunks" option is not supported for "output.inlineDynamicImports".
    at error (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:164:30)
    at getManualChunks (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:20841:20)
    at normalizeOutputOptions (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:20612:23)
    at getOutputOptions (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:20963:12)
    at getOutputOptionsAndPluginDriver (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:20958:12)
    at handleGenerateWrite (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:20935:74)
    at Object.write (node_modules/.pnpm/rollup@2.52.8/node_modules/rollup/dist/shared/rollup.js:20902:20)
    at generate (node_modules/.pnpm/vite@2.4.3/node_modules/vite/dist/node/chunks/dep-f2b4ca46.js:51620:64)
    at doBuild (node_modules/.pnpm/vite@2.4.3/node_modules/vite/dist/node/chunks/dep-f2b4ca46.js:51633:26)
    at async Object.build (node_modules/.pnpm/vite@2.4.3/node_modules/vite/dist/node/chunks/dep-f2b4ca46.js:51457:16)

@benbender
Copy link

+1 same for me. Would be nice, if it gets sorted out!

@paul-schwendenman
Copy link
Author

@benmccann I don't understand your comment. And I don't believe that this issue should have been closed.

First the PR that you mentioned is the same one the I mentioned in the bottom of my initial comment. Was that the one that you intended to link?

Also I pulled the latest of the sveltejs/kit repo and was still able to reproduce the issue. Were you not able to reproduce locally following my instructions?

Please reopen this issue, as it is not resolved to my knowledge.

@benmccann
Copy link
Member

In the description to #1572, @johnnysprinkles said "it allows us to specify manualChunks", so I expected it to work now. And yes, that change has been released. But it looks like I missed that SvelteKit forces a value of inlineDynamicImports that doesn't allow it to work

@benmccann benmccann reopened this Jul 28, 2021
@paul-schwendenman
Copy link
Author

I understand completely how that could be confusing, that PR was merged and the original issue closed before I made this one. Thanks!

@softgripper
Copy link

Hanging out for this one :) My lighthouse score dropped to 99 because of the vendor.js

@bhvngt
Copy link

bhvngt commented Oct 28, 2021

Just checking if anyone has found any work around to this issue.

@benmccann
Copy link
Member

sveltejs/kit@1.0.0-next.192 will allow you to pass inlineDynamicImports: false to address this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants