diff --git a/LICENSE.md b/LICENSE.md index b362d602a05..cdbe1bcf8b9 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -28,12 +28,12 @@ The published Rollup artifact additionally contains code with the following lice MIT, ISC # Bundled dependencies: -## acorn-class-fields +## acorn License: MIT -By: Adrian Heine -Repository: https://github.com/acornjs/acorn-class-fields +By: Marijn Haverbeke, Ingvar Stepanyan, Adrian Heine +Repository: https://github.com/acornjs/acorn.git -> Copyright (C) 2017-2018 by Adrian Heine +> Copyright (C) 2012-2018 by various contributors (see AUTHORS) > > Permission is hereby granted, free of charge, to any person obtaining a copy > of this software and associated documentation files (the "Software"), to deal @@ -55,10 +55,10 @@ Repository: https://github.com/acornjs/acorn-class-fields --------------------------------------- -## acorn-import-meta +## acorn-class-fields License: MIT By: Adrian Heine -Repository: https://github.com/adrianheine/acorn-import-meta +Repository: https://github.com/acornjs/acorn-class-fields > Copyright (C) 2017-2018 by Adrian Heine > @@ -316,33 +316,6 @@ Repository: jonschlinkert/fill-range --------------------------------------- -## fork-acorn-optional-chaining -License: MIT -By: Marijn Haverbeke, Ingvar Stepanyan, Adrian Heine -Repository: https://github.com/acornjs/acorn.git - -> Copyright (C) 2012-2018 by various contributors (see AUTHORS) -> -> Permission is hereby granted, free of charge, to any person obtaining a copy -> of this software and associated documentation files (the "Software"), to deal -> in the Software without restriction, including without limitation the rights -> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -> copies of the Software, and to permit persons to whom the Software is -> furnished to do so, subject to the following conditions: -> -> The above copyright notice and this permission notice shall be included in -> all copies or substantial portions of the Software. -> -> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -> THE SOFTWARE. - ---------------------------------------- - ## glob-parent License: ISC By: Gulp Team, Elan Shanker, Blaine Bublitz diff --git a/package-lock.json b/package-lock.json index c20637fb152..1a4f626981d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -539,18 +539,18 @@ "dev": true }, "acorn": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.2.0.tgz", - "integrity": "sha512-apwXVmYVpQ34m/i71vrApRrRKCWQnZZF1+npOD0WV5xZFfwWOmKGQ2RWlfdy9vWITsenisM8M0Qeq8agcFHNiQ==", + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", + "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", "dev": true }, "acorn-class-fields": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.4.tgz", - "integrity": "sha512-yqUCIu0UJHFmCVhH3Cq29UR+3OJo1CtNWf1ncxTf3KfdEDt7aD0iVYmX7UN+RvIHyOsgukzplQhNkgePtASLUw==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/acorn-class-fields/-/acorn-class-fields-0.3.6.tgz", + "integrity": "sha512-nOzMl1byCFAJLgxNUG7QorpzRHWlkBKVSSOMKUu+bVbVZG5lU4NZkOp/uA7CnE+NAsWhmxTsMgQdHsQXUO8Ulg==", "dev": true, "requires": { - "acorn-private-class-elements": "^0.2.5" + "acorn-private-class-elements": "^0.2.6" } }, "acorn-dynamic-import": { @@ -559,12 +559,6 @@ "integrity": "sha512-d3OEjQV4ROpoflsnUA8HozoIR504TFxNivYEUi6uwz0IYhBkTDXGuWlNdMtybRt3nqVx/L6XqMt0FxkXuWKZhw==", "dev": true }, - "acorn-import-meta": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/acorn-import-meta/-/acorn-import-meta-1.1.0.tgz", - "integrity": "sha512-pshgiVR5mhpjFVdizKTN+kAGRqjJFUOEB3TvpQ6kiAutb1lvHrIVVcGoe5xzMpJkVNifCeymMG7/tsDkWn8CdQ==", - "dev": true - }, "acorn-jsx": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.2.0.tgz", @@ -572,18 +566,18 @@ "dev": true }, "acorn-private-class-elements": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-0.2.5.tgz", - "integrity": "sha512-3eApRrJmPjaxWB3XidP8YMeVq9pcswPFE0KsSWVuhceCU68ZS8fkcf0fTXGhCmnNd7n48NWWV27EKMFPeCoJLg==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/acorn-private-class-elements/-/acorn-private-class-elements-0.2.6.tgz", + "integrity": "sha512-PV+AhOU1/vCx5zIBgGYLB5+OoT8IPKZUcWEGdLBTQgFBMMzPM9S5SKSG4EdiuULqoq3pV3C07rGuSC1Y5gbi/g==", "dev": true }, "acorn-static-class-features": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-0.2.2.tgz", - "integrity": "sha512-B7aWeS7MXqdgP3RnettN/CFz7HevAlQWfh5zkc3LJzeCQoF1InTzYBCfkkbmit1p0pmCEB8IG05gB62pOm5lvA==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/acorn-static-class-features/-/acorn-static-class-features-0.2.3.tgz", + "integrity": "sha512-N7yRI9NduTJRam3BQTXHLR63ykHQv2MnxWTRq0+4PfQosGUz/tM0/ToRqWUqGphP960mDTm/7zJFx3dB/AZtiw==", "dev": true, "requires": { - "acorn-private-class-elements": "^0.2.3" + "acorn-private-class-elements": "^0.2.6" } }, "acorn-walk": { @@ -1837,12 +1831,6 @@ "signal-exit": "^3.0.2" } }, - "fork-acorn-optional-chaining": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/fork-acorn-optional-chaining/-/fork-acorn-optional-chaining-7.2.0.tgz", - "integrity": "sha512-WM85polHQ1XC5XZ/CWBgaFBjKZ2ooTS42Xcp2vpAemHRNubRG6lGZ5ViTcS5pBh9x5VL2yS2gUO3FVwr9vSA+w==", - "dev": true - }, "fromentries": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.2.0.tgz", diff --git a/package.json b/package.json index bf120b674b6..cb5bcaf7fca 100644 --- a/package.json +++ b/package.json @@ -75,11 +75,10 @@ "@types/require-relative": "^0.8.0", "@types/signal-exit": "^3.0.0", "@types/yargs-parser": "^15.0.0", - "acorn": "^7.2.0", - "acorn-class-fields": "^0.3.4", - "acorn-import-meta": "^1.1.0", + "acorn": "^7.3.1", + "acorn-class-fields": "^0.3.6", "acorn-jsx": "^5.2.0", - "acorn-static-class-features": "^0.2.2", + "acorn-static-class-features": "^0.2.3", "acorn-walk": "^7.1.1", "buble": "^0.20.0", "chokidar": "^3.4.0", @@ -94,7 +93,6 @@ "eslint-plugin-import": "^2.21.1", "execa": "^4.0.2", "fixturify": "^2.1.0", - "fork-acorn-optional-chaining": "^7.2.0", "hash.js": "^1.1.7", "husky": "^4.2.5", "is-reference": "^1.2.0", diff --git a/rollup.config.js b/rollup.config.js index 8374803a285..28445f9c021 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -49,8 +49,7 @@ const moduleAliases = { resolve: ['.js', '.json', '.md'], entries: [ { find: 'help.md', replacement: path.resolve('cli/help.md') }, - { find: 'package.json', replacement: path.resolve('package.json') }, - {find: 'acorn', replacement: 'fork-acorn-optional-chaining'} + { find: 'package.json', replacement: path.resolve('package.json') } ] }; diff --git a/src/Graph.ts b/src/Graph.ts index f11a0843f39..85afcfd793f 100644 --- a/src/Graph.ts +++ b/src/Graph.ts @@ -1,4 +1,4 @@ -import * as acorn from 'fork-acorn-optional-chaining'; +import * as acorn from 'acorn'; import GlobalScope from './ast/scopes/GlobalScope'; import { PathTracker } from './ast/utils/PathTracker'; import Chunk from './Chunk'; diff --git a/src/Module.ts b/src/Module.ts index 941a5594d09..bf1788c8b01 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -1,4 +1,4 @@ -import * as acorn from 'fork-acorn-optional-chaining'; +import * as acorn from 'acorn'; import { locate } from 'locate-character'; import MagicString from 'magic-string'; import extractAssignedNames from 'rollup-pluginutils/src/extractAssignedNames'; diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts index f5f71a3ea55..d51977e39c1 100644 --- a/src/ModuleLoader.ts +++ b/src/ModuleLoader.ts @@ -1,4 +1,4 @@ -import * as acorn from 'fork-acorn-optional-chaining'; +import * as acorn from 'acorn'; import ExternalModule from './ExternalModule'; import Graph from './Graph'; import Module from './Module'; diff --git a/src/ast/nodes/CallExpression.ts b/src/ast/nodes/CallExpression.ts index 8cf4a67d393..2bf7a1c5e4f 100644 --- a/src/ast/nodes/CallExpression.ts +++ b/src/ast/nodes/CallExpression.ts @@ -29,7 +29,7 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt annotatedPure?: boolean; arguments!: (ExpressionNode | SpreadElement)[]; callee!: ExpressionNode | Super; - optional?: boolean; + optional!: boolean; type!: NodeType.tCallExpression; private callOptions!: CallOptions; diff --git a/src/ast/nodes/ChainExpression.ts b/src/ast/nodes/ChainExpression.ts new file mode 100644 index 00000000000..77c8a021819 --- /dev/null +++ b/src/ast/nodes/ChainExpression.ts @@ -0,0 +1,9 @@ +import CallExpression from './CallExpression'; +import MemberExpression from './MemberExpression'; +import * as NodeType from './NodeType'; +import { NodeBase } from './shared/Node'; + +export default class ChainExpression extends NodeBase { + expression!: CallExpression | MemberExpression; + type!: NodeType.tChainExpression; +} diff --git a/src/ast/nodes/MemberExpression.ts b/src/ast/nodes/MemberExpression.ts index 11a4c3642ec..8d88d357ef3 100644 --- a/src/ast/nodes/MemberExpression.ts +++ b/src/ast/nodes/MemberExpression.ts @@ -73,7 +73,7 @@ function getStringFromPath(path: PathWithPositions): string { export default class MemberExpression extends NodeBase implements DeoptimizableEntity, PatternNode { computed!: boolean; object!: ExpressionNode | Super; - optional?: boolean; + optional!: boolean; property!: ExpressionNode; propertyKey!: ObjectPathKey | null; type!: NodeType.tMemberExpression; diff --git a/src/ast/nodes/NodeType.ts b/src/ast/nodes/NodeType.ts index 894f007c29f..3f5c69a85eb 100644 --- a/src/ast/nodes/NodeType.ts +++ b/src/ast/nodes/NodeType.ts @@ -9,6 +9,7 @@ export type tBlockStatement = 'BlockStatement'; export type tBreakStatement = 'BreakStatement'; export type tCallExpression = 'CallExpression'; export type tCatchClause = 'CatchClause'; +export type tChainExpression = 'ChainExpression'; export type tClassBody = 'ClassBody'; export type tClassDeclaration = 'ClassDeclaration'; export type tClassExpression = 'ClassExpression'; @@ -78,6 +79,7 @@ export const BlockStatement: tBlockStatement = 'BlockStatement'; export const BreakStatement: tBreakStatement = 'BreakStatement'; export const CallExpression: tCallExpression = 'CallExpression'; export const CatchClause: tCatchClause = 'CatchClause'; +export const ChainExpression: tChainExpression = 'ChainExpression'; export const ClassBody: tClassBody = 'ClassBody'; export const ClassDeclaration: tClassDeclaration = 'ClassDeclaration'; export const ClassExpression: tClassExpression = 'ClassExpression'; diff --git a/src/ast/nodes/index.ts b/src/ast/nodes/index.ts index 3b7ecc5fc96..c5642b92499 100644 --- a/src/ast/nodes/index.ts +++ b/src/ast/nodes/index.ts @@ -9,6 +9,7 @@ import BlockStatement from './BlockStatement'; import BreakStatement from './BreakStatement'; import CallExpression from './CallExpression'; import CatchClause from './CatchClause'; +import ChainExpression from './ChainExpression'; import ClassBody from './ClassBody'; import ClassDeclaration from './ClassDeclaration'; import ClassExpression from './ClassExpression'; @@ -82,6 +83,7 @@ export const nodeConstructors: { BreakStatement, CallExpression, CatchClause, + ChainExpression, ClassBody, ClassDeclaration, ClassExpression, diff --git a/src/utils/options/normalizeInputOptions.ts b/src/utils/options/normalizeInputOptions.ts index 152477a1417..1086b942ef3 100644 --- a/src/utils/options/normalizeInputOptions.ts +++ b/src/utils/options/normalizeInputOptions.ts @@ -1,5 +1,4 @@ import injectClassFields from 'acorn-class-fields'; -import injectImportMeta from 'acorn-import-meta'; import injectStaticClassFeatures from 'acorn-static-class-features'; import { ExternalOption, @@ -114,7 +113,6 @@ const getAcorn = (config: GenericConfigObject): acorn.Options => ({ }); const getAcornInjectPlugins = (config: GenericConfigObject): Function[] => [ - injectImportMeta, injectClassFields, injectStaticClassFeatures, ...(ensureArray(config.acornInjectPlugins) as any) diff --git a/src/utils/pureComments.ts b/src/utils/pureComments.ts index e2f52165b49..c45336a4520 100644 --- a/src/utils/pureComments.ts +++ b/src/utils/pureComments.ts @@ -1,6 +1,6 @@ +import * as acorn from 'acorn'; // @ts-ignore import { base as basicWalker } from 'acorn-walk'; -import * as acorn from 'fork-acorn-optional-chaining'; import { CommentDescription } from '../Module'; // patch up acorn-walk until class-fields are officially supported diff --git a/test/function/samples/options-hook/_config.js b/test/function/samples/options-hook/_config.js index 230a403ca1d..6b30e1daccc 100644 --- a/test/function/samples/options-hook/_config.js +++ b/test/function/samples/options-hook/_config.js @@ -15,7 +15,7 @@ module.exports = { preserveParens: false, sourceType: 'module' }, - acornInjectPlugins: [null, null, null], + acornInjectPlugins: [null, null], context: 'undefined', experimentalCacheExpiry: 10, inlineDynamicImports: false,