Skip to content

Commit

Permalink
avoid to change original options (.acorn) object (#3051)
Browse files Browse the repository at this point in the history
* Update Graph.ts

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update index.ts

* Update utils.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update misc.js

* Update index.ts

* Update utils.js

* Update index.ts

* Update index.ts

* Update utils.js

* Update misc.js

* Update misc.js

* Remove freezes where it is unlikely Rollup will fix them
  • Loading branch information
LongTengDao authored and lukastaegert committed Aug 14, 2019
1 parent 2593b04 commit 4f1d004
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Graph.ts
Expand Up @@ -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);
Expand Down
21 changes: 21 additions & 0 deletions test/misc/misc.js
Expand Up @@ -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 = [];

Expand Down
1 change: 1 addition & 0 deletions test/utils.js
Expand Up @@ -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;
Expand Down

0 comments on commit 4f1d004

Please sign in to comment.