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
Emitted chunk in plugin's transform hook lost after rebuild #2929
Comments
Thanks a lot, definitely an oversight. I know we have special logic to handle this case for assets, but I totally forgot about it for chunks. Hope to find some time soon to fix it. |
Thanks @lukastaegert! In the meanwhile, I found out that using the plugin's cache to store transformations and emitted chunks, I can get it properly work re-emitting chunks: transform(code, id) {
if (this.cache.has(id)) {
const { chunks, result, code: previousCode } = this.cache.get(id);
if (previousCode === code) {
for (let file in chunks) {
this.emitChunk(file);
}
return result;
}
}
let result = /* transformation result... */;
this.cache.set(id, {
code,
result,
chunks,
});
return result;
} It's just a workaround, but it works :D |
Fix at #2933 |
Hi @lukastaegert, I had a test with the new Rollup version, and I noticed that the incremental build works only once. At the secondo rebuild, I still have the original problem... |
Ok, so there is some improvement but not enough. I guess we need to have another go... |
Seems this is also broken for assets, so two issues that might be fixed here together. |
Proper fix that also fixes assets at #2936 |
How Do We Reproduce?
Follow the instruction in this repo: https://gitlab.com/edoardo.cavazza/rollup-watch-emit-chunk
Expected Behavior
Emitted chunks in a plugin's
transform
hook are kept in the bundle cache.Actual Behavior
Emitted chunks are lost after first build. It works if the chunks are emitted in the
load
hook.The text was updated successfully, but these errors were encountered: