Repository navigation
renderChunk hook to replace transformChunk - #2406
Conversation
68cdff5 to
c98761e
Compare
lukastaegert
left a comment
There was a problem hiding this comment.
Dammit, transformChunk was a really nice name. But I guess renderChunk works well enough. Great of you to spot this, especially via other people's code!
Two points:
- Did you contact @surma about this? Would be nice to get some feedback from him if the new hook would work for him and if he has further suggestions how to improve this.
- At some point—at the latest with the 1.0.0 release IMO—we should have deprecation warnings if one of the deprecated hooks is used. As the
transform(Bundle|Chunk)hooks are not that widely used (minification is the only important exception that comes to my mind) we could also consider adding warnings now. Otherwise this should not be forgotten.
| }); | ||
| }); | ||
|
|
||
| it('supports renderChunk in place of transformBundle and transformChunk', () => { |
There was a problem hiding this comment.
To have comprehensive tests for the only Chunk transform hook we want to keep (as of today 😉), I think we should extend this test to check that without returning anything, the output remains unchanged (this is the "get information about the Chunk" part of the hook) and add a second test that only tests that this hook actually transforms the chunk.
There was a problem hiding this comment.
For a long term perspective, I think that actually all transformBundle tests should be reflected in corresponding renderChunk tests as otherwise the new hooks are not nearly as well tested as the old hooks while it should actually be the other way around. Once we reach hard deprecations for the old hooks, quite a few tests can be removed again.
There was a problem hiding this comment.
Agreed, will do.
| } | ||
|
|
||
| export interface OutputChunk { | ||
| export interface RenderChunk { |
There was a problem hiding this comment.
Maybe the name should actually be RenderedChunk as it is not a chunk for rendering but a chunk that will be rendered? This would also match the RenderedModule type nicely.
|
RIP Quick question: The reason I went so deep into the internals ther, is because I needed to figure out if the chunk is an entry module. Now, the |
As mentioned before I will be working on a deprecation PR to ensure all the right alignments here for 1.0, but thanks for following up on this. @surma thanks for trying these new hooks out - it's helped a lot already, I wouldn't have caught this otherwise! The |
|
size-snapshot also uses |
|
@TrySound You are using |
f6171ad to
9c0029a
Compare
f7f8335 to
c5d0f89
Compare
9c0029a to
a769037
Compare
c5d0f89 to
b558402
Compare
a769037 to
d7184f2
Compare
|
(I've rebased this to the watch-events PR for consistent merging) |
d7184f2 to
87b4e49
Compare
|
Thanks, note we shouldn't release until this has been properly documented. Will aim to get something together shortly. |
|
Damn it, was a little quick on this one. Will hold back with tweeting until we have some docs. |
|
No problem, it is backwards compatible so we can just wait on the documentation and note this later on as part of any other release notes. No reason to wait on publicising this, it's more just about ensuring good process that we don't forget these things. |
|
*no reason to wait on publicising the release I mean |
This PR contains:
Breaking Changes?
If yes, please describe the breakage.
Please Describe Your Changes
In the PR #2208 I introduced a breaking change to the transformChunk hook that provided the full
Chunk.tsclass interface as the third argument, completely unintentionally. It also does not match the type and what is documented.There was supposed to be something like this, which got removed while I was working on that (an earlier commit in that same PR) - cc13455#diff-15e7c9d00e111928150170af289cf765.
To change at this point would be breaking (I noticed this in https://github.com/surma/rollup-plugin-loadz0r/blob/master/index.js), so instead the suggestion is to make a new hook "renderChunk" and have it replace "transformChunk" with transformChunk being deprecated as soon as possible. Such a short sweet life this poor hook.
Sincere apologies for this, can tell I was close to burnout back in May :)
The renderChunk hook takes the form
renderChunk (code, { modules, exports, imports, fileName, isEntry }, outputOptions)and is allowed to return a new source to transform the rendered output, exactly as before.The test includes checks for all of these properties, so hopefully we don't have a similar regression anytime soon.