Nâng cấp acorn từ 7.x lên 8.x
So sánh API công khai của acorn 7.4.1 và 8.18.0, được tính tự động từ kiểu TypeScript. Chữ ký thay đổi là thay đổi có thể không tương thích, không phải điều chắc chắn.
Tóm tắt
| Đường dẫn import bị xóa | 0 |
|---|---|
| Export bị xóa | 8 |
| Chữ ký thay đổi | 6 |
| Thành viên lớp hoặc interface bị xóa | 11 |
| Thành viên lớp hoặc interface thay đổi | 15 |
| Mới bị ngừng hỗ trợ | 0 |
| Thay đổi yêu cầu (engines, phụ thuộc peer) | 0 |
| Export mới | 91 |
Export bị xóa
| import | export | kind | Trước |
|---|---|---|---|
acorn | isNewLine | function | (code: number): boolean |
acorn | lineBreak | variable | RegExp |
acorn | TokContext | class | class |
acorn | lineBreakG | variable | RegExp |
acorn | tokContexts | variable | { b_stat: TokContext; b_expr: TokContext; b_tmpl: TokContext; p_stat: TokContext; p_expr: TokContext; q_tmpl: TokContext; f_expr: TokContext; } |
acorn | AbstractToken | interface | interface |
acorn | isIdentifierChar | function | (code: number, astral?: boolean | undefined): boolean |
acorn | isIdentifierStart | function | (code: number, astral?: boolean | undefined): boolean |
Chữ ký thay đổi
| export | Trước | Sau |
|---|---|---|
acorn · Node | class | interface |
acorn · parse | (input: string, options?: Options | undefined): Node | (input: string, options: Options): Program |
acorn · tokTypes | { num: TokenType; regexp: TokenType; string: TokenType; name: TokenType; eof: TokenType; bracketL: TokenType; bracketR: TokenType; braceL: TokenType; braceR: TokenType; parenL: TokenType; parenR: TokenType; comma: TokenType; semi: TokenType; colon: TokenType; dot: TokenType; question: TokenType; arrow: TokenType; template: TokenType; ellipsis: TokenType; backQuote: TokenType; dollarBraceL: TokenType; eq: TokenType; assign: TokenType; incDec: TokenType; prefix: TokenType; logicalOR: TokenType; logicalAND: TokenType; bitwiseOR: TokenType; bitwiseXOR: TokenType; bitwiseAND: TokenType; equality: T… | { num: TokenType; regexp: TokenType; string: TokenType; name: TokenType; privateId: TokenType; eof: TokenType; bracketL: TokenType; bracketR: TokenType; braceL: TokenType; braceR: TokenType; parenL: TokenType; parenR: TokenType; comma: TokenType; semi: TokenType; colon: TokenType; dot: TokenType; question: TokenType; questionDot: TokenType; arrow: TokenType; template: TokenType; invalidTemplate: TokenType; ellipsis: TokenType; backQuote: TokenType; dollarBraceL: TokenType; eq: TokenType; assign: TokenType; incDec: TokenType; prefix: TokenType; logicalOR: TokenType; logicalAND: TokenType; bitwi… |
acorn · tokenizer | (input: string, options?: Options | undefined): { getToken(): Token; [Symbol.iterator](): Iterator<Token, any, any>; } | (input: string, options: Options): { getToken(): Token; [Symbol.iterator](): Iterator<Token, any, any>; } |
acorn · SourceLocation | class | interface |
acorn · parseExpressionAt | (input: string, pos?: number | undefined, options?: Options | undefined): Node | (input: string, pos: number, options: Options): Expression |
Thành viên lớp hoặc interface bị xóa
| member | import | Trước |
|---|---|---|
Node.sourceFile | acorn | string | undefined |
Token.value | acorn | any |
Position.offset | acorn | number |
TokenType.binop | acorn | number |
TokenType.isLoop | acorn | boolean |
TokenType.prefix | acorn | boolean |
TokenType.postfix | acorn | boolean |
TokenType.isAssign | acorn | boolean |
TokenType.beforeExpr | acorn | boolean |
TokenType.startsExpr | acorn | boolean |
TokenType.updateContext | acorn | ((prevType: TokenType) => void) | undefined |
Thành viên lớp hoặc interface thay đổi
| member | Trước | Sau |
|---|---|---|
Node.loc | SourceLocation | undefined | SourceLocation | null | undefined |
Node.constructor | (parser: Parser, pos: number, loc?: SourceLocation | undefined): Node | |
Token.constructor | (p: Parser): Token | (): Token |
Parser.parse | (this: Parser): Node | (): Program |
Parser.static parse | (this: typeof Parser, input: string, options?: Options | undefined): Node | (input: string, options: Options): Program |
Parser.static extend | (this: typeof Parser, ...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser | (...plugins: ((BaseParser: typeof Parser) => typeof Parser)[]): typeof Parser |
Parser.static tokenizer | (this: typeof Parser, input: string, options?: Options | undefined): { getToken(): Token; [Symbol.iterator](): Iterator<Token, any, any>; } | (input: string, options: Options): { getToken(): Token; [Symbol.iterator](): Iterator<Token, any, any>; } |
Parser.static parseExpressionAt | (this: typeof Parser, input: string, pos: number, options?: Options | undefined): Node | (input: string, pos: number, options: Options): Expression |
Comment.type | string | "Line" | "Block" |
Options.onToken | ((token: Token) => any) | Token[] | undefined | ((token: Token) => void) | Token[] | undefined |
Options.sourceType | "script" | "module" | undefined | "script" | "module" | "commonjs" | undefined |
Options.ecmaVersion | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020 | undefined | ecmaVersion |
TokenType.keyword | string | string | undefined |
TokenType.constructor | (label: string, conf?: any): TokenType | (): TokenType |
SourceLocation.constructor | (p: Parser, start: Position, end: Position): SourceLocation | |
Mới bị ngừng hỗ trợ
Không phát hiện.
Thay đổi yêu cầu (engines, phụ thuộc peer)
Không phát hiện.
Export mới (91)
| import | export | kind |
|---|---|---|
acorn | Class | interface |
acorn | Super | interface |
acorn | AnyNode | type |
acorn | Literal | interface |
acorn | Pattern | type |
acorn | Program | interface |
acorn | Function | interface |
acorn | Property | interface |
acorn | ClassBody | interface |
acorn | NodeTypes | interface |
acorn | Statement | type |
acorn | Expression | type |
acorn | Identifier | interface |
acorn | SwitchCase | interface |
acorn | CatchClause | interface |
acorn | Declaration | type |
acorn | IfStatement | interface |
acorn | RestElement | interface |
acorn | StaticBlock | interface |
acorn | ecmaVersion | type |
acorn | ArrayPattern | interface |
acorn | ForStatement | interface |
acorn | MetaProperty | interface |
acorn | TryStatement | interface |
acorn | NewExpression | interface |
acorn | ObjectPattern | interface |
acorn | SpreadElement | interface |
acorn | UnaryOperator | type |
acorn | WithStatement | interface |
acorn | BinaryOperator | type |
acorn | BlockStatement | interface |
acorn | BreakStatement | interface |
acorn | CallExpression | interface |
acorn | EmptyStatement | interface |
acorn | ForInStatement | interface |
acorn | ForOfStatement | interface |
acorn | ThisExpression | interface |
acorn | ThrowStatement | interface |
acorn | UpdateOperator | type |
acorn | WhileStatement | interface |
acorn | ArrayExpression | interface |
acorn | AwaitExpression | interface |
acorn | ChainExpression | interface |
acorn | ClassExpression | interface |
acorn | ExportSpecifier | interface |
acorn | ImportAttribute | interface |
acorn | ImportSpecifier | interface |
acorn | LogicalOperator | type |
acorn | ReturnStatement | interface |
acorn | SwitchStatement | interface |
acorn | TemplateElement | interface |
acorn | TemplateLiteral | interface |
acorn | UnaryExpression | interface |
acorn | YieldExpression | interface |
acorn | BinaryExpression | interface |
acorn | ClassDeclaration | interface |
acorn | DoWhileStatement | interface |
acorn | ImportExpression | interface |
acorn | LabeledStatement | interface |
acorn | MemberExpression | interface |
acorn | MethodDefinition | interface |
acorn | ObjectExpression | interface |
acorn | UpdateExpression | interface |
acorn | AssignmentPattern | interface |
acorn | ContinueStatement | interface |
acorn | DebuggerStatement | interface |
acorn | ImportDeclaration | interface |
acorn | LogicalExpression | interface |
acorn | ModuleDeclaration | type |
acorn | PrivateIdentifier | interface |
acorn | AssignmentOperator | type |
acorn | AssignmentProperty | interface |
acorn | FunctionExpression | interface |
acorn | PropertyDefinition | interface |
acorn | SequenceExpression | interface |
acorn | VariableDeclarator | interface |
acorn | ExpressionStatement | interface |
acorn | FunctionDeclaration | interface |
acorn | VariableDeclaration | interface |
acorn | AssignmentExpression | interface |
acorn | ExportAllDeclaration | interface |
acorn | ConditionalExpression | interface |
acorn | ExportNamedDeclaration | interface |
acorn | ImportDefaultSpecifier | interface |
acorn | ArrowFunctionExpression | interface |
acorn | ParenthesizedExpression | interface |
acorn | ExportDefaultDeclaration | interface |
acorn | ImportNamespaceSpecifier | interface |
acorn | TaggedTemplateExpression | interface |
acorn | AnonymousClassDeclaration | interface |
acorn | AnonymousFunctionDeclaration | interface |
Changelog giữa các phiên bản này
Văn bản do tác giả gói công bố, hiển thị nguyên trạng.
8.18.0
### New features
The new `startLocation` option can now be used to tell the parser the line and column the parse starts at (mostly useful with `parseExpressionAt`).
### Bug fixes
Reject uses of `**` with a non-parenthesized arrow function as left-hand side.
Avoid computing the start line in `parseExpressionAt` when locations aren't used.8.17.0
### New features
The new `strict` option can be used to start script sources in strict mode.
### Bug fixes
Fix a number of corner case bugs when `using` or `await using` appear in `for` loop specs.
Disallow `new super()` expressions.
Don't allow the conditional in a ternary expression to be a (naked) arrow function.8.16.0
### New features
The `sourceType` option can now be set to `"commonjs"` to have the parser treat the top level scope as a function scope.
Add support for Unicode 17.
### Bug fixes
Don't recognize `await using` as contextual keywords when followed directly by a backslash.
Fix an issue where the parser would allow `return` statements in `static` blocks when `allowReturnOutsideFunction` was enabled.
Properly reject `using` declarations that appear directly in `switch` or `for` head scopes.
Fix some corner case issues in the recognition of `using` syntax.8.15.0
### New features
Support `using` and `await using` syntax.
The `AnyNode` type is now defined in such a way that plugins can extend it.
### Bug fixes
Fix an issue where the `bigint` property of literal nodes for non-decimal bigints had the wrong format.
The `acorn` CLI tool no longer crashes when emitting a tree that contains a bigint.8.14.1
### Bug fixes
Fix an issue where `await` expressions in class field initializers were inappropriately allowed.
Properly allow await inside an async arrow function inside a class field initializer.
Mention the source file name in syntax error messages when given.
Properly add an empty `attributes` property to every form of `ExportNamedDeclaration`.8.14.0
### New features
Support ES2025 import attributes.
Support ES2025 RegExp modifiers.
### Bug fixes
Support some missing Unicode properties.8.13.0
### New features
Upgrade to Unicode 16.0.8.12.1
### Bug fixes
Fix a regression that caused Acorn to no longer run on Node versions <8.10.8.12.0
### New features
Support ES2025 duplicate capture group names in regular expressions.
### Bug fixes
Include `VariableDeclarator` in the `AnyNode` type so that walker objects can refer to it without getting a type error.
Properly raise a parse error for invalid `for`/`of` statements using `async` as binding name.
Properly recognize \"use strict\" when preceded by a string with an escaped newline.
Mark the `Parser` constructor as protected, not private, so plugins can extend it without type errors.
Fix a bug where some invalid `delete` expressions were let through when the operand was parenthesized and `preserveParens` was enabled.
Properly normalize line endings in raw strings of invalid template tokens.
Properly track line numbers for escaped newlines in strings.
Fix a bug that broke line number accounting after a template literal with invalid escape sequences.8.11.3
### Bug fixes
Add `Function` and `Class` to the `AggregateType` type, so that they can be used in walkers without raising a type error.
Make sure `onToken` get an `import` keyword token when parsing `import.meta`.
Fix a bug where `.loc.start` could be undefined for `new.target` `meta` nodes.8.11.2
### Bug fixes
Fix a bug that caused regular expressions after colon tokens to not be properly tokenized in some circumstances.8.11.1
### Bug fixes
Fix a regression where `onToken` would receive 'name' tokens for 'new' keyword tokens.8.11.0
### Bug fixes
Fix an issue where tokenizing (without parsing) an object literal with a property named `class` or `function` could, in some circumstance, put the tokenizer into an invalid state.
Fix an issue where a slash after a call to a propery named the same as some keywords would be tokenized as a regular expression.
### New features
Upgrade to Unicode 15.1.
Use a set of new, much more precise, TypeScript types.8.10.0
### New features
Add a `checkPrivateFields` option that disables strict checking of private property use.8.9.0
### Bug fixes
Forbid dynamic import after `new`, even when part of a member expression.
### New features
Add Unicode properties for ES2023.
Add support for the `v` flag to regular expressions.8.8.2
### Bug fixes
Fix a bug that caused `allowHashBang` to be set to false when not provided, even with `ecmaVersion >= 14`.
Fix an exception when passing no option object to `parse` or `new Parser`.
Fix incorrect parse error on `if (0) let\n[astral identifier char]`.8.8.1
### Bug fixes
Make type for `Comment` compatible with estree types.8.8.0
### Bug fixes
Allow parentheses around spread args in destructuring object assignment.
Fix an issue where the tree contained `directive` properties in when parsing with a language version that doesn't support them.
### New features
Support hashbang comments by default in ECMAScript 2023 and later.8.7.1
### Bug fixes
Stop handling `"use strict"` directives in ECMAScript versions before 5.
Fix an issue where duplicate quoted export names in `export *` syntax were incorrectly checked.
Add missing type for `tokTypes`.8.7.0
### New features
Support quoted export names.
Upgrade to Unicode 14.
Add support for Unicode 13 properties in regular expressions.
### Bug fixes
Use a loop to find line breaks, because the existing regexp search would overrun the end of the searched range and waste a lot of time in minified code.8.6.0
### Bug fixes
Fix a bug where an object literal with multiple `__proto__` properties would incorrectly be accepted if a later property value held an assigment.
### New features
Support class private fields with the `in` operator.8.5.0
### Bug fixes
Improve context-dependent tokenization in a number of corner cases.
Fix location tracking after a 0x2028 or 0x2029 character in a string literal (which before did not increase the line number).
Fix an issue where arrow function bodies in for loop context would inappropriately consume `in` operators.
Fix wrong end locations stored on SequenceExpression nodes.
Implement restriction that `for`/`of` loop LHS can't start with `let`.
### New features
Add support for ES2022 class static blocks.
Allow multiple input files to be passed to the CLI tool.8.4.1
### Bug fixes
Fix a bug where `allowAwaitOutsideFunction` would allow `await` in class field initializers, and setting `ecmaVersion` to 13 or higher would allow top-level await in non-module sources.8.4.0
### New features
A new option, `allowSuperOutsideMethod`, can be used to suppress the error when `super` is used in the wrong context.8.3.0
### New features
Default `allowAwaitOutsideFunction` to true for ECMAScript 2022 an higher.
Add support for the `d` ([indices](https://github.com/tc39/proposal-regexp-match-indices)) regexp flag.8.2.4
### Bug fixes
Fix spec conformity in corner case 'for await (async of ...)'.8.2.3
### Bug fixes
Fix an issue where the library couldn't parse 'for (async of ...)'.
Fix a bug in UTF-16 decoding that would read characters incorrectly in some circumstances.8.2.2
### Bug fixes
Fix a bug where a class field initialized to an async arrow function wouldn't allow await inside it. Same issue existed for generator arrow functions with yield.8.2.1
### Bug fixes
Fix a regression introduced in 8.2.0 where static or async class methods with keyword names fail to parse.8.2.0
### New features
Add support for ES2022 class fields and private methods.8.1.1
### Various
Stop shipping source maps in the NPM package.8.1.0
### Bug fixes
Fix a spurious error in nested destructuring arrays.
### New features
Expose `allowAwaitOutsideFunction` in CLI interface.
Make `allowImportExportAnywhere` also apply to `import.meta`.8.0.5
### Bug fixes
Adjust package.json to work with Node 12.16.0 and 13.0-13.6.8.0.4
### Bug fixes
Make `await x ** y` an error, following the spec.
Fix potentially exponential regular expression.8.0.3
### Bug fixes
Fix a wasteful loop during `Parser` creation when setting `ecmaVersion` to `"latest"`.8.0.2
### Bug fixes
Make the TypeScript types reflect the current allowed values for `ecmaVersion`.
Fix another regexp/division tokenizer issue.8.0.1
### Bug fixes
Provide the correct value in the `version` export.8.0.0
### Bug fixes
Disallow expressions like `(a = b) = c`.
Make non-octal escape sequences a syntax error in strict mode.
### New features
The package can now be loaded directly as an ECMAScript module in node 13+.
Update to the set of Unicode properties from ES2021.
### Breaking changes
The `ecmaVersion` option is now required. For the moment, omitting it will still work with a warning, but that will change in a future release.
Some changes to method signatures that may be used by plugins.Câu hỏi thường gặp
Nâng cấp acorn từ 7 lên 8 có những thay đổi không tương thích nào?
Giữa acorn 7.4.1 và 8.18.0, Vigia tìm thấy 8 export bị xóa, 6 chữ ký thay đổi và 26 thành viên lớp hoặc interface bị xóa hay thay đổi.
Những gì bị ngừng hỗ trợ trong acorn 8?
0 export hoặc thành viên mới bị đánh dấu ngừng hỗ trợ trong acorn 8.18.0.
Dành cho tác tử
GET https://vigia.coredls.cloud/v1/packages/npm/acorn/upgrade?from=7.4.1&to=8.18.0