-
-
Notifications
You must be signed in to change notification settings - Fork 183
code splitting multiple vendor chunks #181
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
Comments
I have this issue as well. The main blocker for me is that when you have enough entry points, the names of chunks which need to be loaded for multiple entry points truncate, so I can't use the name to understand which file goes to which entry point. |
I was able to find the entry point in the new ManifestPlugin({
generate: (seed, files) =>
files.reduce((manifest, file) => {
const fileData = { path: file.path };
if (file.chunk && file.chunk.groupsIterable) {
fileData.entries = [];
for(group of file.chunk.groupsIterable) {
if(group.options && group.options.name) {
fileData.entries.push(group.options.name);
}
}
}
return {
...manifest,
[file.name]: fileData
};
}, seed)
}) |
To generate a manifest like {[entry_name]: ['ordered.js', 'list.js', 'of.js', 'chunks.js']} I've got the following (seed, files) => {
const entrypoints = new Set()
files.forEach(
(file) => ((file.chunk || {})._groups || []).forEach(
(group) => entrypoints.add(group)
)
)
const entries = [...entrypoints]
const entryArrayManifest = entries.reduce((acc, entry) => {
const name = (entry.options || {}).name
|| (entry.runtimeChunk || {}).name
const files = [].concat(
...(entry.chunks || []).map((chunk) => chunk.files)
).filter(Boolean)
return name ? {...acc, [name]: files} : acc
}, seed)
return entryArrayManifest
} This results in something like {
"foo": [
"vendors~bar~foo.a1258721c436b463b51d.js",
"foo.78f40b8c23cc6cbf3fa7.js"
],
"bar": [
"vendors~bar~foo.a1258721c436b463b51d.js",
"bar.a07432c2585ba2ae3d31.js"
]
} which is pretty much what is what webpack outputs:
EDIT: none of the |
@SKalt is |
_groups is an array property of each file object emitted by webpack. |
@SKalt I think Your script should be included as a helper parameter in manifest plugin. Great work! |
fixed by #192 |
For future reference: I built this generator module on top of this module +1 year ago, partly based on the ideas in #181 (comment): https://github.com/Sydsvenskan/node-asset-versions/blob/master/example/webpack.config.js with generator method being defined here: https://github.com/Sydsvenskan/node-asset-versions/blob/a63b074cf03327a2a9b4e4a355432f96a9b8d4f1/lib/manifest-generator.js#L11-L21 |
webpack version
"webpack": "4.22.0",
Currently the manifest file only generates the following format for multiple entries and the default split chunks configuration:
With splitting the vendors, the entrypoints definitely output a list of chunks associated per entry:
Any way I can get the entire list added to the manifest?
The text was updated successfully, but these errors were encountered: