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

Named chunks plugin #4553

Merged
merged 7 commits into from
Apr 4, 2017
Merged

Named chunks plugin #4553

merged 7 commits into from
Apr 4, 2017

Conversation

timse
Copy link
Member

@timse timse commented Mar 23, 2017

What kind of change does this PR

feature

Did you add tests for your changes?

TBD

If relevant, link to documentation update:

TBD

Summary

based on the work of #3436
Allow chunk ids to be a string, provide NamedChunksPlugin that accepts a name resolver function to resolve chunks into names.
This would also allow things like #2682

Does this PR introduce a breaking change?

No

Other information

Happy to add proper testing once its ok to go this direction @sokra

@timse timse force-pushed the named-chunks-plugin branch from f27dfc2 to 50a7335 Compare March 26, 2017 09:35
@webpack-bot
Copy link
Contributor

The most important CI builds succeeded. Great work so far.

@Pavel910
Copy link

Pavel910 commented Apr 2, 2017

@timse Tested this locally on my current client project, seems to solve the problem for me with custom named chunks! 👍 🍻

@sokra Hoping to see this in the upcoming release. Would be greatly appreciated! Thanks

@sokra
Copy link
Member

sokra commented Apr 4, 2017

Thanks

@lucaperret
Copy link

Hi @timse, Can I use your NamedChunksPlugin to output chunks with a static name ?

I have this output webpack config that generate chunks filename containing chunkhash:
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
And in plugins:

new webpack.optimize.CommonsChunkPlugin({
    name: 'static-named-chunk',
    chunks: ['static-named-chunk'],
    filename: utils.assetsPath('js/[name].js')
})

That generate the chunk with good filename static-named-chunk.js.
But the manifest still reference the chunkhash and his corresponding id.

Thanks for your help

@timse timse deleted the named-chunks-plugin branch April 7, 2017 13:49
@timse
Copy link
Member Author

timse commented Apr 7, 2017

@lucaperret see here: https://github.com/webpack/webpack/pull/4553/files#diff-fdd2eb1e89fc79f2b86af37851152b92

not sure what exactly you look after, but u need to use this plugin to specify a name if you want a name.
Especially for non entry chunks which have no names, you need to come up with a name yourself.

@lucaperret
Copy link

lucaperret commented Apr 7, 2017

@timse I use require.ensure([], require => require('./a'), 'my-async-chunk') to create my async named chunk.
The generated files contain chunkhash because of:
chunkFilename: '[id].[chunkhash].js'
Can I override this behaviour to generate static name like my-async-chunk.js only for specific chunk(s) ?

@timse
Copy link
Member Author

timse commented Apr 7, 2017

I doubt that, thats also not the purpose of this plugin.

@azzgo
Copy link

azzgo commented Apr 12, 2017

Nice Work, That is exactly the feature our team needed. By the way, when will the feature release?

@mikegreiling
Copy link
Member

when can we tag v2.3.4 with this change?

@abhinavsingi
Copy link

@bebraw

bebraw referenced this pull request on Mar 25
Open
Named chunks using System.imports #3132

This PR doesn't solve #3132 or #2369 as they refer to dynamic chunks loading and this one is to change the actual loading of chunks names

@dinvlad
Copy link

dinvlad commented Feb 24, 2018

I noticed that for async modules, this plugin sets "Chunks" but not "Chunk Names" (https://github.com/webpack/webpack/pull/4553/files#diff-fe6fc5dc520112c616934d9ae8a8b087). This is not the case if we use either a static /* webpackChunkName: "<chunkName>" */ (but keep the modules async) or for sync modules. Does that have any negative consequences in terms of chunk loading?

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.

10 participants