Skip to content

Commit 01d632d

Browse files
BridgeARtargos
authored andcommitted
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: #27400 Refs: #27391 Refs: #25835 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent c0ab2a1 commit 01d632d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/internal/repl/await.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ const { Object } = primordials;
44

55
const acorn = require('internal/deps/acorn/acorn/dist/acorn');
66
const walk = require('internal/deps/acorn/acorn-walk/dist/walk');
7+
const privateMethods =
8+
require('internal/deps/acorn-plugins/acorn-private-methods/index');
9+
const bigInt = require('internal/deps/acorn-plugins/acorn-bigint/index');
10+
const classFields =
11+
require('internal/deps/acorn-plugins/acorn-class-fields/index');
12+
const numericSeparator =
13+
require('internal/deps/acorn-plugins/acorn-numeric-separator/index');
14+
const staticClassFeatures =
15+
require('internal/deps/acorn-plugins/acorn-static-class-features/index');
16+
17+
const parser = acorn.Parser.extend(
18+
privateMethods,
19+
bigInt,
20+
classFields,
21+
numericSeparator,
22+
staticClassFeatures
23+
);
724

825
const noop = () => {};
926
const visitorsWithoutAncestors = {
@@ -76,7 +93,7 @@ function processTopLevelAwait(src) {
7693
const wrappedArray = wrapped.split('');
7794
let root;
7895
try {
79-
root = acorn.parse(wrapped, { ecmaVersion: 10 });
96+
root = parser.parse(wrapped, { ecmaVersion: 10 });
8097
} catch {
8198
return null;
8299
}

0 commit comments

Comments
 (0)