File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,10 @@ function shouldUseESMLoader(mainPath) {
462
462
const userLoader = getOptionValue ( '--experimental-loader' ) ;
463
463
if ( userLoader )
464
464
return true ;
465
+ const experimentalSpecifierResolution =
466
+ getOptionValue ( '--experimental-specifier-resolution' ) ;
467
+ if ( experimentalSpecifierResolution === 'node' )
468
+ return true ;
465
469
// Determine the module format of the main
466
470
if ( mainPath && mainPath . endsWith ( '.mjs' ) )
467
471
return true ;
Original file line number Diff line number Diff line change 1
1
// Flags: --experimental-modules --experimental-specifier-resolution=node
2
2
import { mustNotCall } from '../common/index.mjs' ;
3
3
import assert from 'assert' ;
4
+ import path from 'path' ;
5
+ import { spawn } from 'child_process' ;
6
+ import { fileURLToPath } from 'url' ;
4
7
5
8
// commonJS index.js
6
9
import commonjs from '../fixtures/es-module-specifiers/package-type-commonjs' ;
@@ -33,3 +36,24 @@ async function main() {
33
36
}
34
37
35
38
main ( ) . catch ( mustNotCall ) ;
39
+
40
+ // Test path from command line arguments
41
+ [
42
+ 'package-type-commonjs' ,
43
+ 'package-type-module' ,
44
+ '/' ,
45
+ '/index' ,
46
+ ] . forEach ( ( item ) => {
47
+ const modulePath = path . join (
48
+ fileURLToPath ( import . meta. url ) ,
49
+ '../../fixtures/es-module-specifiers' ,
50
+ item ,
51
+ ) ;
52
+ spawn ( process . execPath , [
53
+ '--experimental-modules' ,
54
+ '--es-module-specifier-resolution=node' ,
55
+ modulePath
56
+ ] , { stdio : 'inherit' } ) . on ( 'exit' , ( code ) => {
57
+ assert . strictEqual ( code , 0 ) ;
58
+ } ) ;
59
+ } ) ;
You can’t perform that action at this time.
0 commit comments