@@ -20,20 +20,21 @@ import {
20
20
import { getConfigPrompt , getMultiConfigPrompt } from './prompt.js' ;
21
21
22
22
const ExperimentalModuleLoader = ( ) => {
23
- const getInfo = ( packageName : string ) => {
24
- const entryPath = require . resolve ( packageName ) ;
25
- const location = entryPath . split ( packageName ) [ 0 ] + packageName ;
23
+ const getInfo = async ( packageName : string ) => {
24
+ // @ts -expect-error Experimental loader
25
+ const entryPath = import . meta. resolve ( packageName ) ;
26
+ // @ts -expect-error Experimental loader
27
+ const location = ( entryPath . split ( packageName ) [ 0 ] + packageName ) . replace (
28
+ 'file://' ,
29
+ '' ,
30
+ ) ;
26
31
const pkgJsonRaw = fs . readFileSync (
27
- path . join ( location , 'package.json' ) ,
32
+ path . join ( location . replace ( 'file://' , '' ) , 'package.json' ) ,
28
33
'utf8' ,
29
34
) ;
30
35
const pkgJson = JSON . parse ( pkgJsonRaw ) ;
31
36
32
- return {
33
- location,
34
- entryPath,
35
- pkgJson,
36
- } ;
37
+ return { location, entryPath, pkgJson } ;
37
38
} ;
38
39
39
40
const install = async ( packageName : string ) => {
@@ -44,7 +45,7 @@ const ExperimentalModuleLoader = () => {
44
45
additionalArgs : [ '--force' ] ,
45
46
} ) ;
46
47
47
- const { pkgJson } = getInfo ( packageName ) ;
48
+ const { pkgJson } = await getInfo ( packageName ) ;
48
49
49
50
// Install whitelisted devDependencies
50
51
if ( pkgJson ?. hypermod ?. dependencies ) {
@@ -65,7 +66,7 @@ const ExperimentalModuleLoader = () => {
65
66
return {
66
67
install,
67
68
getInfo,
68
- require : ( packageName : string ) => require ( packageName ) ,
69
+ require : async ( packageName : string ) => import ( packageName ) ,
69
70
} ;
70
71
} ;
71
72
0 commit comments