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

runtimeChunk and splitChunk settings collide #7382

Closed
timse opened this issue May 24, 2018 · 3 comments · Fixed by #7386 or #7387
Closed

runtimeChunk and splitChunk settings collide #7382

timse opened this issue May 24, 2018 · 3 comments · Fixed by #7386 or #7387

Comments

@timse
Copy link
Member

timse commented May 24, 2018

Bug report

runtimeChunk: single produces multiple runtime chunks if spitChunks minSize settings is very small.

What is the current behavior?
settings

splitChunks: {
    minSize: 0
}

will basically ignore the runtimeChunk: 'single' setting and produce a runtime chunk per entry.

If the current behavior is a bug, please provide the steps to reproduce.

see above

What is the expected behavior?

a single runtime chunk for all entries.

Other relevant information:
webpack version: latest
Node.js version: latest
Operating System: osx
Additional tools: -

basically, this behavior can be "fixed" by removing the module count check here: https://github.com/webpack/webpack/blob/master/lib/optimize/RuntimeChunkPlugin.js#L22

which causes the unwanted behavior. However, I do not know if there is a valid reason for that checks existance.

@chrisdarroch
Copy link

I'm interested in this problem because of how having multiple runtimes plays havoc with code that expects to only ever load and be evaluated once.

Since the webpack runtime includes a locally-scoped installedModules object, any double-up of the runtime means a potential for a shared module to evaluate twice. This is problematic for modules that register side-effects, like DOM event handlers.

Yeah, I know that in an ideal world, shared modules shouldn't exhibit such behaviour and should be idempotent. In reality, we've been able to register these as AMD modules and avoid multiple inclusions or evaluations of them. Only now when running the modules through webpack 4 are we experiencing this problem.

sokra added a commit that referenced this issue May 24, 2018
@sokra
Copy link
Member

sokra commented May 26, 2018

Could you check if this is fixed in 4.9.1?

@chrisdarroch
Copy link

Yep @sokra, I'm getting a single runtime in 4.9.1. Thanks for fixing this so quickly!

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