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 targos committed Jan 14, 2022
1 parent d83a029 commit e457ec0
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
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
@@ -0,0 +1,3 @@
export function testFunction(req, res) {
return 'PASS';
}
1 change: 1 addition & 0 deletions test/sequential/test-cli-syntax-good.js
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 e457ec0

Please sign in to comment.