const acorn = {};
rollup({
input: 'main.js',
acorn,
experimentalTopLevelAwait: true,
}).then(()=>{
console.log(acorn.allowAwaitOutsideFunction);// true, then rollup below will work incorrectly
rollup({
input: 'main.js',
acorn,
experimentalTopLevelAwait: false,
});
});
https://github.com/rollup/rollup/blob/2443783d0b1214ab742373414ed03d4f0f75964f/src/Graph.ts#L171
https://github.com/rollup/rollup/blob/2443783d0b1214ab742373414ed03d4f0f75964f/src/Graph.ts#L178
https://github.com/rollup/rollup/blob/2443783d0b1214ab742373414ed03d4f0f75964f/src/Graph.ts#L179
https://github.com/rollup/rollup/blob/2443783d0b1214ab742373414ed03d4f0f75964f/src/Graph.ts#L180
Thanks for the issue and PR :beer:
Please add a more verbose description to the issue. It's not immediately obvious what you're attempting to resolve. That will also give the associated PR more context.
@shellscape
If options.experimentalTopLevelAwait is true, then rollup function will modify acornOptions.allowAwaitOutsideFunction to true (line 179), but acornOptions is the original options.acorn (line 171).
Then the original options.acorn object is modified. If user uses same object as option, problem happens.
In next rollup, user uses the same options.acorn object, with options.experimentalTopLevelAwait false, the rollup run as if the experimentalTopLevelAwait is true.
const acorn = { ecmaVersion: 5 };// multi use option object
await rollup({ input: '1.js', acorn, experimentalTopLevelAwait: true });
await rollup({ input: '2.js', acorn, experimentalTopLevelAwait: false });
// wrong processing, because acorn object was modified
I believe this is resolved now