Skip to content

Commit

Permalink
Remove acorn-bigint and acorn-dynamic-import from bundle (#3058)
Browse files Browse the repository at this point in the history
* Update Graph.ts

* Update package.json

* Update declarations.d.ts

* Update rollup.config.js

* Update rollup.config.js

* Update rollup.config.js

* Fix acorn import

* Switch ECMAVersion to 2020
  • Loading branch information
LongTengDao authored and lukastaegert committed Aug 14, 2019
1 parent d18c12b commit 2593b04
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 48 deletions.
63 changes: 33 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@
"homepage": "https://github.com/rollup/rollup",
"dependencies": {
"@types/estree": "0.0.39",
"@types/node": "^12.6.9",
"acorn": "^6.2.1"
"@types/node": "^12.7.1",
"acorn": "^6.3.0"
},
"devDependencies": {
"@types/chokidar": "^2.1.3",
"@types/micromatch": "^3.1.0",
"@types/minimist": "^1.2.0",
"acorn-bigint": "^0.4.0",
"acorn-dynamic-import": "^4.0.0",
"acorn-import-meta": "^1.0.0",
"acorn-jsx": "^5.0.1",
"acorn-walk": "^6.2.0",
Expand All @@ -83,7 +81,7 @@
"execa": "^2.0.3",
"fixturify": "^1.2.0",
"hash.js": "^1.1.7",
"husky": "^3.0.2",
"husky": "^3.0.3",
"immutable": "^4.0.0-rc.12",
"is-reference": "^1.1.3",
"lint-staged": "^9.2.1",
Expand All @@ -99,10 +97,10 @@
"pretty-ms": "^5.0.0",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^1.18.0",
"rollup": "^1.19.4",
"rollup-plugin-alias": "^1.5.2",
"rollup-plugin-buble": "^0.19.8",
"rollup-plugin-commonjs": "^10.0.1",
"rollup-plugin-commonjs": "^10.0.2",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
Expand All @@ -117,7 +115,7 @@
"source-map-support": "^0.5.13",
"sourcemap-codec": "^1.4.6",
"systemjs": "^5.0.0",
"terser": "^4.1.2",
"terser": "^4.1.4",
"tslib": "^1.10.0",
"tslint": "^5.18.0",
"turbocolor": "^2.6.1",
Expand Down
5 changes: 2 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function addSheBang() {
};
}

const expectedAcornImport = "import acorn__default, { tokTypes, Parser } from 'acorn';";
const expectedAcornImport = "import acorn__default, { Parser } from 'acorn';";
const newAcornImport =
"import * as acorn__default from 'acorn';\nimport { tokTypes, Parser } from 'acorn';";
"import * as acorn__default from 'acorn';\nimport { Parser } from 'acorn';";

// by default, rollup-plugin-commonjs will translate require statements as default imports
// which can cause issues for secondary tools that use the ESM version of acorn
Expand All @@ -81,7 +81,6 @@ function fixAcornEsmImport() {

const moduleAliases = {
resolve: ['.js', '.json', '.md'],
'acorn-dynamic-import': path.resolve('node_modules/acorn-dynamic-import/src/index.js'),
'help.md': path.resolve('cli/help.md'),
'package.json': path.resolve('package.json')
};
Expand Down
4 changes: 0 additions & 4 deletions src/Graph.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as acorn from 'acorn';
import injectBigInt from 'acorn-bigint';
import injectDynamicImportPlugin from 'acorn-dynamic-import';
import injectImportMeta from 'acorn-import-meta';
import * as ESTree from 'estree';
import GlobalScope from './ast/scopes/GlobalScope';
Expand Down Expand Up @@ -171,9 +169,7 @@ export default class Graph {
this.acornOptions = options.acorn || {};
const acornPluginsToInject = [];

acornPluginsToInject.push(injectDynamicImportPlugin);
acornPluginsToInject.push(injectImportMeta);
acornPluginsToInject.push(injectBigInt);

if (options.experimentalTopLevelAwait) {
(this.acornOptions as any).allowAwaitOutsideFunction = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export interface AstContext {
}

export const defaultAcornOptions: acorn.Options = {
ecmaVersion: 2019,
ecmaVersion: 2020 as any,
preserveParens: false,
sourceType: 'module'
};
Expand Down
2 changes: 0 additions & 2 deletions typings/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ declare module 'date-time';
declare module 'locate-character';
declare module 'is-reference';
declare module 'require-relative';
declare module 'acorn-dynamic-import';
declare module 'acorn-import-meta';
declare module 'acorn-bigint';

0 comments on commit 2593b04

Please sign in to comment.