diff --git a/src/Graph.ts b/src/Graph.ts index 0a974892693..eeddda18f30 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -166,7 +166,7 @@ export default class Graph { this.getModuleContext = () => this.context; } - this.acornOptions = options.acorn || {}; + this.acornOptions = options.acorn ? Object.assign({}, options.acorn) : {}; const acornPluginsToInject = []; acornPluginsToInject.push(injectImportMeta); diff --git a/test/misc/misc.js b/test/misc/misc.js index 4640a9fcbd7..2cd6bf0878a 100644 --- a/test/misc/misc.js +++ b/test/misc/misc.js @@ -3,6 +3,27 @@ const rollup = require('../../dist/rollup'); const { loader } = require('../utils.js'); describe('misc', () => { + it('throw modification of options or its property', () => { + const { freeze } = Object; + return rollup.rollup( + freeze({ + input: 'input', + external: freeze([]), + plugins: freeze([ + { + name: 'loader', + resolveId: freeze(() => 'input'), + load: freeze(() => `export default 0;`) + } + ]), + acornInjectPlugins: freeze([]), + acorn: freeze({}), + experimentalTopLevelAwait: true, + treeshake: freeze({}) + }) + ); + }); + it('warns if node builtins are unresolved in a non-CJS, non-ES bundle (#1051)', () => { const warnings = []; diff --git a/test/utils.js b/test/utils.js index d21f62e33d9..2506c74d9d7 100644 --- a/test/utils.js +++ b/test/utils.js @@ -117,6 +117,7 @@ function removeOldTest(dir) { } function loader(modules) { + modules = Object.assign(Object.create(null), modules); return { resolveId(id) { return id in modules ? id : null;