@@ -17,20 +17,21 @@ import { fetchConfigsForWorkspaces, getPackageJson } from './utils/file-system';
1717import { getConfigPrompt , getMultiConfigPrompt } from './prompt' ;
1818
1919const ExperimentalModuleLoader = ( ) => {
20- const getInfo = ( packageName : string ) => {
21- const entryPath = require . resolve ( packageName ) ;
22- const location = entryPath . split ( packageName ) [ 0 ] + packageName ;
20+ const getInfo = async ( packageName : string ) => {
21+ // @ts -expect-error Experimental loader
22+ const entryPath = import . meta. resolve ( packageName ) ;
23+ // @ts -expect-error Experimental loader
24+ const location = ( entryPath . split ( packageName ) [ 0 ] + packageName ) . replace (
25+ 'file://' ,
26+ '' ,
27+ ) ;
2328 const pkgJsonRaw = fs . readFileSync (
24- path . join ( location , 'package.json' ) ,
29+ path . join ( location . replace ( 'file://' , '' ) , 'package.json' ) ,
2530 'utf8' ,
2631 ) ;
2732 const pkgJson = JSON . parse ( pkgJsonRaw ) ;
2833
29- return {
30- location,
31- entryPath,
32- pkgJson,
33- } ;
34+ return { location, entryPath, pkgJson } ;
3435 } ;
3536
3637 const install = async ( packageName : string ) => {
@@ -40,7 +41,7 @@ const ExperimentalModuleLoader = () => {
4041 additionalArgs : [ '--force' ] ,
4142 } ) ;
4243
43- const { pkgJson } = getInfo ( packageName ) ;
44+ const { pkgJson } = await getInfo ( packageName ) ;
4445
4546 // Install whitelisted devDependencies
4647 if ( pkgJson ?. hypermod ?. dependencies ) {
@@ -61,7 +62,7 @@ const ExperimentalModuleLoader = () => {
6162 return {
6263 install,
6364 getInfo,
64- require : ( packageName : string ) => require ( packageName ) ,
65+ require : async ( packageName : string ) => import ( packageName ) ,
6566 } ;
6667} ;
6768
0 commit comments