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

Fix parsing webpack 4's chunks #159

Merged
merged 3 commits into from
Mar 1, 2018

Conversation

jdelStrother
Copy link
Contributor

Webpack 4 has a new chunk loading style, looking something like this:

(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{"57iH":function(e,n,t){console.log("hello world")}}]);

WDYT to this approach?

Webpack 4 has a new chunk style, looking something like this:

(window.webpackJsonp=window.webpackJsonp||[]).push([[27],{"57iH":function(e,n,t){console.log("hello world")}}]);
@jsf-clabot
Copy link

jsf-clabot commented Mar 1, 2018

CLA assistant check
All committers have signed the CLA.

@valscion valscion self-assigned this Mar 1, 2018
@valscion
Copy link
Member

valscion commented Mar 1, 2018

Hi, and welcome! Thank you for your PR ☺️

I was wondering, is there any case where the "minimum ID" is needed? The [27] part in your example. Is there a way for webpack 4 to generate numerical IDs instead of these modules keyed by a hash of some sort?

This PR in itself looks great! Would you be open to checking whether there's new sorts of chunk loading styles that also start with the (window.webpackJsonp=window.webpackJsonp||[]).push approach? Something similar to this:

As you can see in the above example, the module IDs are affected by the ID in the first parameter.

Figuring this out can be done outside of this PR, though — this can go in on itself.

Could you create a changelog entry to CHANGELOG.md and link back to this PR, similarly to how the links have been done in v2.10.0 and above?

@jdelStrother
Copy link
Contributor Author

I was wondering, is there any case where the "minimum ID" is needed? The [27] part in your example. Is there a way for webpack 4 to generate numerical IDs instead of these modules keyed by a hash of some sort?

Yeah, re-reading it, the minimum id isn't necessary to calculate the ids in the chunk, so it's misleadingly named. I'll change it.

Would you be open to checking whether there's new sorts of chunk loading styles

The only place where I could find webpackJsonp being used is here - https://github.com/webpack/webpack/blob/master/lib/web/JsonpChunkTemplatePlugin.js. There's an optional third argument (entries), which happens to work ok with my original code, but I'll add a test to confirm it.

Could you create a changelog entry to CHANGELOG.md and link back to this PR

will do

@valscion
Copy link
Member

valscion commented Mar 1, 2018

The only place where I could find webpackJsonp being used is here - https://github.com/webpack/webpack/blob/master/lib/web/JsonpChunkTemplatePlugin.js. There's an optional third argument (entries), which happens to work ok with my original code, but I'll add a test to confirm it.

👍

I'll add a non-master link to the file in question so it won't get lost if files are moved around as webpack is developed: https://github.com/webpack/webpack/blob/v4.0.1/lib/web/JsonpChunkTemplatePlugin.js

@valscion
Copy link
Member

valscion commented Mar 1, 2018

Looks great! Thank you for contributing! 🎉

@valscion valscion merged commit ba3dbd7 into webpack-contrib:master Mar 1, 2018
@valscion
Copy link
Member

valscion commented Mar 1, 2018

Released in v2.11.1 🎉

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

Successfully merging this pull request may close these issues.

3 participants