Skip to content

Commit

Permalink
lib: fix checking syntax of esm module
Browse files Browse the repository at this point in the history
Fixes: nodejs#41189

PR-URL: nodejs#41198
Refs: nodejs#37468
Reviewed-By: Derek Lewis <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
  • Loading branch information
Ayase-252 authored Dec 19, 2021
1 parent 0fcae7b commit 3f7dabd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/main/check_syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function checkSyntax(source, filename) {
const { defaultResolve } = require('internal/modules/esm/resolve');
const { defaultGetFormat } = require('internal/modules/esm/get_format');
const { url } = defaultResolve(pathToFileURL(filename).toString());
const { format } = defaultGetFormat(url);
const format = defaultGetFormat(url);
isModule = format === 'module';
}
if (isModule) {
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/syntax/good_syntax.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function testFunction(req, res) {
return 'PASS';
}
1 change: 1 addition & 0 deletions test/sequential/test-cli-syntax-good.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const syntaxArgs = [
[
'syntax/good_syntax.js',
'syntax/good_syntax',
'syntax/good_syntax.mjs',
'syntax/good_syntax_shebang.js',
'syntax/good_syntax_shebang',
'syntax/illegal_if_not_wrapped.js',
Expand Down

0 comments on commit 3f7dabd

Please sign in to comment.