Skip to content

Commit

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

PR-URL: #41198
Refs: #37468
Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
Ayase-252 authored and danielleadams committed Feb 1, 2022
1 parent e7d57ac commit a47fc90
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 a47fc90

Please sign in to comment.