Skip to content

Commit e8a4c6a

Browse files
committed
Added support for exported field of ExportAllDeclaration
1 parent ab53cd5 commit e8a4c6a

6 files changed

+20
-6
lines changed

escodegen.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -1275,14 +1275,23 @@
12751275

12761276
ExportAllDeclaration: function (stmt, flags) {
12771277
// export * FromClause ;
1278-
return [
1278+
var result = [
12791279
'export' + space,
1280-
'*' + space,
1280+
'*' + space
1281+
];
1282+
1283+
if (stmt.exported) {
1284+
result.push('as ' + stmt.exported.name + ' ');
1285+
}
1286+
1287+
result = join(result, [
12811288
'from' + space,
12821289
// ModuleSpecifier
12831290
this.generateExpression(stmt.source, Precedence.Sequence, E_TTT),
12841291
this.semicolon(flags)
1285-
];
1292+
]);
1293+
1294+
return result;
12861295
},
12871296

12881297
ExpressionStatement: function (stmt, flags) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"source-map": "~0.6.1"
4040
},
4141
"devDependencies": {
42-
"acorn": "^7.3.1",
42+
"acorn": "^8.0.1",
4343
"bluebird": "^3.4.7",
4444
"bower-registry-client": "^1.0.0",
4545
"chai": "^4.2.0",

test/compare-acorn-es2020.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ function test(code, expected) {
3939
options = {
4040
ranges: false,
4141
locations: false,
42-
ecmaVersion: 11
42+
ecmaVersion: 11,
43+
sourceType: 'module'
4344
};
4445

4546
tree = acorn.parse(code, options);
@@ -58,7 +59,8 @@ function testMin(code, expected) {
5859
options = {
5960
ranges: false,
6061
locations: false,
61-
ecmaVersion: 11
62+
ecmaVersion: 11,
63+
sourceType: 'module'
6264
};
6365

6466
tree = acorn.parse(code, options);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as name from 'OK';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export*as name from'OK'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * as name from 'OK';

0 commit comments

Comments
 (0)