Skip to content

Commit

Permalink
Acorn 7.3.0 upgrade (#3628)
Browse files Browse the repository at this point in the history
* Acorn 7.3.0 upgrade

* retain fork for previous build, lock file update

* walker typing work-around

* 7.3.1

* update acorn plugins

* fixup hook test

* Get rid of acorn fork, introduce missing ChainExpression node to fix test

* Fix type with regard to ESTree types

Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
Co-authored-by: Lukas Taegert-Atkinson <lukastaegert@users.noreply.github.com>
  • Loading branch information
3 people committed Jun 12, 2020
1 parent ad24b6a commit 872e9e2
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 75 deletions.
39 changes: 6 additions & 33 deletions LICENSE.md
Expand Up @@ -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
Expand All @@ -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
>
Expand Down Expand Up @@ -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
Expand Down
40 changes: 14 additions & 26 deletions package-lock.json

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

8 changes: 3 additions & 5 deletions package.json
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 1 addition & 2 deletions rollup.config.js
Expand Up @@ -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') }
]
};

Expand Down
2 changes: 1 addition & 1 deletion 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';
Expand Down
2 changes: 1 addition & 1 deletion 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';
Expand Down
2 changes: 1 addition & 1 deletion 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';
Expand Down
2 changes: 1 addition & 1 deletion src/ast/nodes/CallExpression.ts
Expand Up @@ -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;
Expand Down
9 changes: 9 additions & 0 deletions 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;
}
2 changes: 1 addition & 1 deletion src/ast/nodes/MemberExpression.ts
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/ast/nodes/NodeType.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions src/ast/nodes/index.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -82,6 +83,7 @@ export const nodeConstructors: {
BreakStatement,
CallExpression,
CatchClause,
ChainExpression,
ClassBody,
ClassDeclaration,
ClassExpression,
Expand Down
2 changes: 0 additions & 2 deletions 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,
Expand Down Expand Up @@ -114,7 +113,6 @@ const getAcorn = (config: GenericConfigObject): acorn.Options => ({
});

const getAcornInjectPlugins = (config: GenericConfigObject): Function[] => [
injectImportMeta,
injectClassFields,
injectStaticClassFeatures,
...(ensureArray(config.acornInjectPlugins) as any)
Expand Down
2 changes: 1 addition & 1 deletion 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
Expand Down
2 changes: 1 addition & 1 deletion test/function/samples/options-hook/_config.js
Expand Up @@ -15,7 +15,7 @@ module.exports = {
preserveParens: false,
sourceType: 'module'
},
acornInjectPlugins: [null, null, null],
acornInjectPlugins: [null, null],
context: 'undefined',
experimentalCacheExpiry: 10,
inlineDynamicImports: false,
Expand Down

0 comments on commit 872e9e2

Please sign in to comment.