@@ -20,20 +20,21 @@ import {
2020import { getConfigPrompt , getMultiConfigPrompt } from './prompt.js' ;
2121
2222const 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+ ) ;
2631 const pkgJsonRaw = fs . readFileSync (
27- path . join ( location , 'package.json' ) ,
32+ path . join ( location . replace ( 'file://' , '' ) , 'package.json' ) ,
2833 'utf8' ,
2934 ) ;
3035 const pkgJson = JSON . parse ( pkgJsonRaw ) ;
3136
32- return {
33- location,
34- entryPath,
35- pkgJson,
36- } ;
37+ return { location, entryPath, pkgJson } ;
3738 } ;
3839
3940 const install = async ( packageName : string ) => {
@@ -44,7 +45,7 @@ const ExperimentalModuleLoader = () => {
4445 additionalArgs : [ '--force' ] ,
4546 } ) ;
4647
47- const { pkgJson } = getInfo ( packageName ) ;
48+ const { pkgJson } = await getInfo ( packageName ) ;
4849
4950 // Install whitelisted devDependencies
5051 if ( pkgJson ?. hypermod ?. dependencies ) {
@@ -65,7 +66,7 @@ const ExperimentalModuleLoader = () => {
6566 return {
6667 install,
6768 getInfo,
68- require : ( packageName : string ) => require ( packageName ) ,
69+ require : async ( packageName : string ) => import ( packageName ) ,
6970 } ;
7071} ;
7172
0 commit comments