mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
lib: fix checking syntax of esm module
Fixes: https://github.com/nodejs/node/issues/41189 PR-URL: https://github.com/nodejs/node/pull/41198 Refs: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
0fcae7ba16
commit
3f7dabdfdc
@ -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) {
|
||||
|
3
test/fixtures/syntax/good_syntax.mjs
vendored
Normal file
3
test/fixtures/syntax/good_syntax.mjs
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export function testFunction(req, res) {
|
||||
return 'PASS';
|
||||
}
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user