Rollup: This line would change the origin option object

Created on 12 Aug 2019  路  3Comments  路  Source: rollup/rollup

  • Rollup Version: 1.19.4
  • Operating System (or Browser):
  • Node Version:

How Do We Reproduce?

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,
  });
});

Expected Behavior

Actual Behavior

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

s鲁 馃敟 nice to have t鹿 馃悶 bug

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Uyarn picture Uyarn  路  3Comments

Announcement picture Announcement  路  3Comments

alendit picture alendit  路  3Comments

ashubham picture ashubham  路  3Comments

good-idea picture good-idea  路  3Comments