@@ -3,9 +3,7 @@ import semver from 'semver';
33import chalk from 'chalk' ;
44import findUp from 'find-up' ;
55import inquirer from 'inquirer' ;
6- import fs from 'fs-extra' ;
7- import { PluginManager , PluginManagerOptions } from 'live-plugin-manager' ;
8- import { installPackage } from '@antfu/install-pkg' ;
6+ import { PluginManagerOptions } from 'live-plugin-manager' ;
97
108import * as core from '@hypermod/core' ;
119import { fetchConfigAtPath } from '@hypermod/fetcher' ;
@@ -16,56 +14,6 @@ import { mergeConfigs } from './utils/merge-configs';
1614import { fetchConfigsForWorkspaces , getPackageJson } from './utils/file-system' ;
1715import { getConfigPrompt , getMultiConfigPrompt } from './prompt' ;
1816
19- const ExperimentalModuleLoader = ( ) => {
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- ) ;
28- const pkgJsonRaw = fs . readFileSync (
29- path . join ( location . replace ( 'file://' , '' ) , 'package.json' ) ,
30- 'utf8' ,
31- ) ;
32- const pkgJson = JSON . parse ( pkgJsonRaw ) ;
33-
34- return { location, entryPath, pkgJson } ;
35- } ;
36-
37- const install = async ( packageName : string ) => {
38- await installPackage ( packageName , {
39- cwd : __dirname ,
40- packageManager : 'npm' ,
41- additionalArgs : [ '--force' ] ,
42- } ) ;
43-
44- const { pkgJson } = await getInfo ( packageName ) ;
45-
46- // Install whitelisted devDependencies
47- if ( pkgJson ?. hypermod ?. dependencies ) {
48- await Promise . all (
49- pkgJson . hypermod . dependencies . map ( ( dep : string ) => {
50- const version = pkgJson . devDependencies [ dep ] ;
51- if ( ! version ) return ;
52- return installPackage ( `${ dep } @${ version } ` , {
53- cwd : __dirname ,
54- packageManager : 'npm' ,
55- additionalArgs : [ '--force' ] ,
56- } ) ;
57- } ) ,
58- ) ;
59- }
60- } ;
61-
62- return {
63- install,
64- getInfo,
65- require : async ( packageName : string ) => import ( packageName ) ,
66- } ;
67- } ;
68-
6917export default async function main (
7018 paths : string [ ] ,
7119 flags : Partial < core . Flags > ,
@@ -92,10 +40,6 @@ export default async function main(
9240 } ;
9341 }
9442
95- const packageManager = flags . experimentalLoader
96- ? ExperimentalModuleLoader ( )
97- : new PluginManager ( pluginManagerConfig ) ;
98-
9943 let transforms : string [ ] = [ ] ;
10044
10145 if ( ! flags . transform && ! flags . packages ) {
@@ -234,11 +178,7 @@ export default async function main(
234178 . filter ( id => id . startsWith ( '#' ) )
235179 . map ( id => id . substring ( 1 ) ) ;
236180
237- const { community, remote } = await fetchPackages (
238- pkgName ,
239- // @ts -expect-error Experimental loader
240- packageManager ,
241- ) ;
181+ const { community, remote } = await fetchPackages ( pkgName ) ;
242182
243183 const config = mergeConfigs ( community , remote ) ;
244184
0 commit comments