Skip to content

Commit

Permalink
fix(parser): improved module code parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
KFlash committed Nov 6, 2019
1 parent 01db03c commit 9ecef95
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meriyah",
"version": "1.8.7",
"version": "1.9.0",
"description": "A 100% compliant, self-hosted javascript parser with high focus on both performance and stability",
"main": "dist/meriyah.umd.js",
"module": "dist/meriyah.esm.js",
Expand Down
2 changes: 1 addition & 1 deletion src/meriyah.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ export function parse(source: string, options?: Options): ESTree.Program {
export { Options, ESTree };

// Current version
export const version = '1.8.7';
export const version = '1.9.0';
19 changes: 13 additions & 6 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2878,7 +2878,9 @@ function parseExportDeclaration(

nextToken(parser, context); // Skips: '*'

if (consumeOpt(parser, context, Token.AsKeyword)) {
const isNamedDeclaration = consumeOpt(parser, context, Token.AsKeyword);

if (isNamedDeclaration) {
if (scope) declareUnboundVariable(parser, parser.tokenValue);
specifiers.push(
finishNode(parser, context, parser.tokenPos, parser.linePos, parser.colPos, {
Expand All @@ -2896,11 +2898,16 @@ function parseExportDeclaration(

matchOrInsertSemicolon(parser, context | Context.AllowRegExp);

return finishNode(parser, context, start, line, column, {
type: 'ExportNamedDeclaration',
source,
specifiers
} as any);
return isNamedDeclaration
? finishNode(parser, context, start, line, column, {
type: 'ExportNamedDeclaration',
source,
specifiers
} as any)
: finishNode(parser, context, start, line, column, {
type: 'ExportAllDeclaration',
source
} as any);
}
case Token.LeftBrace: {
// ExportClause :
Expand Down
2 changes: 1 addition & 1 deletion test/parser/module/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ describe('Module - Export', () => {
},
specifiers: [],
start: 0,
type: 'ExportNamedDeclaration'
type: 'ExportAllDeclaration'
}
],
end: 17,
Expand Down

0 comments on commit 9ecef95

Please sign in to comment.