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
Manual chunks function #2831
Manual chunks function #2831
Conversation
…oints and manual chunks
points and introducing a manualChunkAlias for colouring to resolve this confusing double use of chunkAlias
* Allow manual chunks to contain entry points without name or with the same name * Throw if an emitted chunk is not found * Throw if there is a conflict between manual chunk entries * Allow nesting of manual chunks without requiring a specific order
- if the alias matches, the manual chunk becomes the entry chunk - otherwise a facade is created
@lukastaegert you're awesome, thanks so much for this! |
ed8d480
to
261d6ca
Compare
# Conflicts: # src/Graph.ts # src/ModuleLoader.ts # src/rollup/types.d.ts # test/function/samples/manual-chunks-conflict/_config.js
@lukastaegert thanks so much for working on this! One question, you said:
I'm assuming here that you mean all its dependencies not already in their own chunks, correct? E.g. I'm assuming it would be possible to put all npm dependencies into their own chunks, even if they have cross references to other npm dependencies, correct? |
Yes, you are correct. I was not sure how to express this well without going too much into technical details. The way this works is that each time you return a string, the string is assigned to the module as a label. Then in a later stage when the manual chunks are created, we start with each labelled module and then assign the same label to all its dependencies unless the dependency already has a label. |
@lukastaegert really appreciate this PR. One question my |
Yes, the return value just replaces the |
Thanks - appreciate the quick response! |
@lukastaegert thanks for the clarification. I'm trying it out now, and it works great! |
How does one apply the hash conditionally? I've wanted to separate the preload chunk from normal chunks and thought this function was my key; but I got number ordered chunk names when I tried it, which are less optimal cache-wise. |
Different naming patterns are not yet implemented but there is an issue around this that I hope we will be able to address at some point: #2793 |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #2688, resolves #2336
Description
This will allow the
manualChunks
option to be a function. If that is the case, all module ids are passed to this function. If this function returns a string, the given module and all its dependencies are added to the manual chunk with the given name.This makes it possible to e.g. create vendor chunks via
All combinatorics should work, if they don't, please let me know. There also should not be any issues any more if some of the files are dependencies of other files.