repl: add new language features to top level await statements
This adds stage-3 language features to acorn so that it's possible to parse these features when using top level await in the REPL. PR-URL: https://github.com/nodejs/node/pull/27400 Refs: https://github.com/nodejs/node/issues/27391 Refs: https://github.com/nodejs/node/issues/25835 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
This commit is contained in:
parent
04b7c007d6
commit
f37e40af2b
@ -4,6 +4,23 @@ const { Object } = primordials;
|
|||||||
|
|
||||||
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
|
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
|
||||||
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
|
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
|
||||||
|
const privateMethods =
|
||||||
|
require('internal/deps/acorn-plugins/acorn-private-methods/index');
|
||||||
|
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
|
||||||
|
const classFields =
|
||||||
|
require('internal/deps/acorn-plugins/acorn-class-fields/index');
|
||||||
|
const numericSeparator =
|
||||||
|
require('internal/deps/acorn-plugins/acorn-numeric-separator/index');
|
||||||
|
const staticClassFeatures =
|
||||||
|
require('internal/deps/acorn-plugins/acorn-static-class-features/index');
|
||||||
|
|
||||||
|
const parser = acorn.Parser.extend(
|
||||||
|
privateMethods,
|
||||||
|
bigInt,
|
||||||
|
classFields,
|
||||||
|
numericSeparator,
|
||||||
|
staticClassFeatures
|
||||||
|
);
|
||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
const visitorsWithoutAncestors = {
|
const visitorsWithoutAncestors = {
|
||||||
@ -76,7 +93,7 @@ function processTopLevelAwait(src) {
|
|||||||
const wrappedArray = wrapped.split('');
|
const wrappedArray = wrapped.split('');
|
||||||
let root;
|
let root;
|
||||||
try {
|
try {
|
||||||
root = acorn.parse(wrapped, { ecmaVersion: 10 });
|
root = parser.parse(wrapped, { ecmaVersion: 10 });
|
||||||
} catch {
|
} catch {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user