-
-
Notifications
You must be signed in to change notification settings - Fork 269
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
[rollup-plugin-polyfills-loader] Possible race condition while writing polyfile scripts to disk. #2456
Comments
I recommend creating a minimal reproduction, that usually highlights the issue pretty quickly. |
Hi again! Ok - I've created a minimal project, and either I'm hitting the bug all the time, or I've configured something wrong. The 'polyfills'-folder is not created no matter what I try. Could you try this out, and confirm whether or not the polyfills-folder is created for you?
I was expecting Cheers! |
There still seems to be quite a lot going on in the rollup config, can you try reducing that even more? |
Yes - could've been smaller. I've updated the rollup config in the previous reply so that it's more basic now. |
We set
When using multiple outputs, I see that in the
I tried to wrap the whole async generateBundle(_, bundle) {
setTimeout(() => {
if (generatedFiles) {
for (const file of generatedFiles) {
// if the polyfills loader is used multiple times, this polyfill might already be output
// so we guard against that. polyfills are already hashed, so there is no need to worry
// about clashing
if (!(file.path in bundle)) {
this.emitFile({
type: 'asset',
name: file.path,
fileName: file.path,
source: file.content,
});
}
}
}
})
}, However, I still don't see them being output to |
It appears as the html transformer is called after the generateBundle hook? |
I've tried to follow the source code to understand what is happening. Looks like the html-transformer that creates Maybe the html-transformer could emit the files if the number of bundles are more than 1? |
I created a test based on the ones in <h1>Hello world</h1>
<script type="module">import "./entrypoint-a.js";</script>
<script type="module" src="./entrypoint-b.js"></script> should output <html><head></head><body><h1>Hello world</h1>
<script type="module" src="./inline-module-5ec680a4efbb48ae254268ab1defe610.js"></script>
<script type="module" src="./entrypoint-b.js"></script>
</body></html> For multiple src there are a race condition, giving random order. |
Here is the actual test i wrote for rollup-plugin-html.test.ts it('can resolve modules in original order', async () => {
const config = {
plugins: [
rollupPluginHTML({
rootDir,
input: {
name: 'index.html',
html: '<h1>Hello world</h1>' +
'<script type="module">import "./entrypoint-a.js";</script>' +
'<script type="module" src="./entrypoint-b.js"></script>',
},
}),
],
};
const bundle = await rollup(config);
const { output } = await bundle.generate(outputConfig);
expect(output.length).to.equal(4);
const hash = '5ec680a4efbb48ae254268ab1defe610';
const { code: appCode } = getChunk(output, `inline-module-${hash}.js`);
expect(appCode).to.include("console.log('entrypoint-a.js');");
expect(stripNewlines(getAsset(output, 'index.html').source)).to.equal(
'<html><head></head><body><h1>Hello world</h1>' +
'<script type="module" src="./inline-module-5ec680a4efbb48ae254268ab1defe610.js"></script>' +
'<script type="module" src="./entrypoint-b.js"></script>' +
'</body></html>',
);
}); |
found the problem. Working on a patch. |
Hi!
I'm having some trouble with getting the polyfill javascript files written to disk. They are only sometimes generated into the polyfills folder - more often if my system is under heavy load. So, I suspect a race condition of some sort.
Below is the config I use:
Any ideas or pointers on how to solve this?
Cheers!
The text was updated successfully, but these errors were encountered: