Skip to content
This repository was archived by the owner on Apr 16, 2020. It is now read-only.

Commit 98f4d99

Browse files
committed
fixup: this is better
1 parent 3336300 commit 98f4d99

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/internal/modules/esm/default_resolve.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const { NativeModule } = require('internal/bootstrap/loaders');
44
const { ERR_TYPE_MISMATCH,
55
ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes;
66
const { getOptionValue } = require('internal/options');
7-
const optionType = getOptionValue('--type');
87
const experimentalJsonModules = getOptionValue('--experimental-json-modules');
98
const { resolve: moduleWrapResolve } = internalBinding('module_wrap');
109
const { pathToFileURL, fileURLToPath } = require('internal/url');
@@ -77,8 +76,8 @@ function resolve(specifier, parentURL) {
7776
}
7877
}
7978
if (!format) {
80-
if (isMain && type === 0 && optionType)
81-
format = optionType;
79+
if (isMain && asyncESM.typeFlag)
80+
format = asyncESM.typeFlag;
8281
else if (isMain)
8382
format = type === 2 ? 'module' : 'commonjs';
8483
else

test/es-module/test-esm-no-extension.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ const assert = require('assert');
77

88
const entry = fixtures.path('/es-modules/noext-esm');
99

10-
const child = spawn(process.execPath, ['--experimental-modules', '--type=module', entry]);
10+
const child = spawn(process.execPath, [
11+
'--experimental-modules',
12+
'--type=module',
13+
entry
14+
]);
15+
1116
let stderr = '';
1217
child.stderr.setEncoding('utf8');
1318
child.stderr.on('data', (data) => {

0 commit comments

Comments
 (0)