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 <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent c0ab2a1 commit 01d632d

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

‎lib/internal/repl/await.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ const { Object } = primordials;
44

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

825
constnoop=()=>{};
926
constvisitorsWithoutAncestors={
@@ -76,7 +93,7 @@ function processTopLevelAwait(src) {
7693
constwrappedArray=wrapped.split('');
7794
letroot;
7895
try{
79-
root=acorn.parse(wrapped,{ecmaVersion: 10});
96+
root=parser.parse(wrapped,{ecmaVersion: 10});
8097
}catch{
8198
returnnull;
8299
}

0 commit comments

Comments
 (0)