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: Only include initial chunks #48

Merged
merged 2 commits into from
Jul 6, 2017
Merged

Conversation

a-x-
Copy link
Contributor

@a-x- a-x- commented Jul 3, 2017

closes #46 Do not add code splitting bundles into manifest

@mastilver
Copy link
Contributor

Do we need the omitDlls options?

Couldn't you use chunk.initial or chunk.isInitial()?

@a-x-
Copy link
Contributor Author

a-x- commented Jul 3, 2017

What is chunk.initial or chunk.isInitial()?
I cannot find them in the source code or documentation

@mastilver
Copy link
Contributor

mastilver commented Jul 3, 2017

it's a boolean on chunk that tell if they are required on initial run

.filter(chunk => chunk.isInitial ? chunk. isInitial() : chunk.initial

@a-x-
Copy link
Contributor Author

a-x- commented Jul 3, 2017

Thank you,

As I understand isInitial might be a replacement for the chunk.entrypoints in that case.

But I'm not sure to make this new logic default for all users in the next minor version.

@mastilver
Copy link
Contributor

I doubt it can be considered as a breaking change,
to me it's definitely a fix, so it should land on a patch (BTW, some tests would be great! ;) )

lib/plugin.js Outdated
// Don't add hot updates to manifest
if (file.indexOf('hot-update') >= 0) {
_.merge(manifest, compilation.chunks
.filter(chunk => chunk => chunk.isInitial ? chunk.isInitial() : chunk.initial)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra chunk =>

@a-x-
Copy link
Contributor Author

a-x- commented Jul 3, 2017

done

@mastilver mastilver changed the title opt.omitDlls: import() and require.ensure skipping fix: Don't include initial chunks Jul 3, 2017
Copy link
Contributor

@mastilver mastilver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, thank you 👍
I will release that later

@mastilver mastilver changed the title fix: Don't include initial chunks fix: Only include initial chunks Jul 6, 2017
@mastilver mastilver merged commit 90a04af into shellscape:master Jul 6, 2017
@a-x- a-x- deleted the patch-2 branch July 6, 2017 21:32
@a-x- a-x- restored the patch-2 branch July 6, 2017 21:33
@Ianfeather
Copy link

@mastilver Hi! First of all thanks for your work on this project, we use it in the asset-pipeline at BuzzFeed.

Unfortunately this change broke one of our applications this morning as it was relying on the dynamic chunks being included in the asset-manifest. We use these manifest entries to preload bundles ahead of time with link[rel=preload]. We can probably find some alternative but it would be great if you would consider having this as an option. I think this is a very legitimate use case.

@a-x-
Copy link
Contributor Author

a-x- commented Jul 7, 2017

Hey, we wanted to make it optional initially 😂

@mastilver
Copy link
Contributor

@Ianfeather Damn, I was really hoping for my first release to go smoothly... :/

I will revert that change for now, we can think for another solution later

@a-x-
Copy link
Contributor Author

a-x- commented Jul 7, 2017

@Ianfeather, you should use chunk-manifest-webpack-plugin. I'm sorry about this

my position, this change should be default but major
@mastilver, what about you?

mastilver added a commit that referenced this pull request Jul 7, 2017
@mastilver
Copy link
Contributor

@Ianfeather webpack-manifest-plugin@1.0.2 released :)

@mastilver
Copy link
Contributor

@a-x- I thing the right path to take is: by default include every single possible assets into the manifest and be able to have some filtering, I will put my thought down on an issue over the week-end, I will be happy to get your thoughts on that ;)

@a-x-
Copy link
Contributor Author

a-x- commented Jul 7, 2017

ok, I can restore initial flagged functionality

@mastilver
Copy link
Contributor

@a-x- I want to work on something more modular, it will solve your issue and few others

In the meantime, I would love to get some help on #51 as I won't be merging anything else until that's done. that way I'm sure we don't introduce new breaking changes

@Ianfeather
Copy link

@mastilver Thanks for your quick turnaround on this! It's much appreciated.

@a-x- thanks for the link to that project. That will also help us remove our webpack-runtime script too

if (file.indexOf('hot-update') >= 0) {
_.merge(manifest, compilation.chunks
.filter(chunk => chunk.isInitial ? chunk.isInitial() : chunk.initial)
.reduce(function(memo, chunk) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like if we use (memo, chunk) => {...} we get the right context and we can skip .bind(this)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zuzusik You are right, but it can't happens before #53
I did the mistake of merging this PR without caring for older node versions
I added tests to prevent this kind of mistake in the future

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, got it


// Map original chunk name to output files.
// For nameless chunks, just map the files directly.
return chunk.files.reduce(function(memo, file) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as /~https://github.com/danethurber/webpack-manifest-plugin/pull/48/files#r126661193, but will work only in combination with the previous (e.g. if both functions are arrow)

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 this pull request may close these issues.

Do not add code splitting bundles into manifest
4 participants