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
Structure lifecycle hooks, add links to build time hooks #3418
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3418 +/- ##
=======================================
Coverage 93.29% 93.29%
=======================================
Files 172 172
Lines 6112 6112
Branches 1822 1822
=======================================
Hits 5702 5702
Misses 218 218
Partials 192 192 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great. The split between 'build' and 'output generation' really improved my understanding here.
Co-Authored-By: Jake Archibald <jaffathecake@gmail.com>
I finished adding the remaining links to the output generation hooks and addressing the current review comments. Please have a look if you see anything that could be improved. Also note that I am still no native speaker so if you think something could be spelled out in a more natural way, do not hesitate to comment 😜 |
Thanks. And yes, this is something that I stumbled upon myself while extending the documentation. E.g. resolveId and resolveDynamicImport are a build phase hook while resolveFileUrl and resolveImportMeta are output generation hooks, the naming does not really help here. As most plugins will probably be concerned mainly with one of the two phases, this split seemed helpful to me and you confirmed this. In retrospective, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although it still isn't clear to be when Rollup performs hashing, dead code removal, splitting etc.
@@ -225,20 +225,21 @@ You can use [`this.getModuleInfo`](guide/en/#thisgetmoduleinfomoduleid-string--m | |||
#### `watchChange` | |||
Type: `(id: string) => void`<br> | |||
Kind: `sync, sequential`<br> | |||
Previous/Next Hook: This hook can be triggered at any time both during the build and the output generation phases. | |||
Previous/Next Hook: This hook can be triggered at any time both during the build and the output generation phases. If that is the case, the current build will still proceed but a new build will be scheduled to start once the current build has completed, starting again with [`options`](guide/en/#options). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I was never sure if build re-runs were sometimes shortcut. This makes it clear.
In case it's useful, here's how I interpreted the steps: A CLI build will do the following:
If in watch mode, and any watched file changes, immediately hook: The rollup API will let you call build and generate output separately. To build:
To load module:
To generate output:
|
Nice, this looks quite good! Minor points:
|
Well, that was not the question you asked 😉. So to answer it: hashing is performed just after the Dead code elimination (or rather "tree-shaking" as we like to call it here 😄) is performed once all modules are loaded, so between the last Code-splitting is also done in the build phase at the moment, after tree-shaking and before Also there is some demand to open it up more to plugins e.g. to merge small chunks. It would be nicer if this was possible per output. |
Isn't that what I wrote? See step 6 of build.
Ohh nice! I've updated the post. What about
Isn't that covered in the next step: If writing…
Hmmm kinda? In #3409 (comment) I call out that it's currently difficult to figure out the order in which hooks are called, and how it relates to the rest of Rollup's processing. I also called out #2739 - it isn't clear from the docs that
Is that also when asset hashing happens?
Hmm ok. Is hashing likely to be redone in the next 6 months? Otherwise it might be worth noting it, to avoid more confusion like #2739. I've added the other steps too, but noted that hashing and splitting are likely to move. Thanks for taking the time to work on this! |
Yes, but it does not happen at the end of "build", it happens at the end of "generate output" for the last output
Yes
Ah, I overlooked this 👍
Ok sorry, seems my mind had simplified this a little too much.
No, those are currently hashed when they are emitted or their source is set as you cannot change the source later.
I would think so. Documentation alone will not prevent new bugs from appearing here I fear.
And thanks for pushing here! There are some comments from you that I will also add later before publishing this. |
Ah, in step 7 of build I call out to generate output, so the watch stuff does happen after generate. I think the problem here is I've rolled generate output into build, whereas in the guide you've kept them seperate. I'll do the same to match. Done! I've added "A CLI build will do the following:" to tie them together. |
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
Resolves #3409
Description
This will
This is still WIP. The build phase is already done, I hope to finish the output generation phase until tomorrow. Feedback already welcome.