@@ -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' ;
@@ -19,57 +17,6 @@ import {
1917} from './utils/file-system.js' ;
2018import { getConfigPrompt , getMultiConfigPrompt } from './prompt.js' ;
2119
22- const ExperimentalModuleLoader = ( ) => {
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- ) ;
31- const pkgJsonRaw = fs . readFileSync (
32- path . join ( location . replace ( 'file://' , '' ) , 'package.json' ) ,
33- 'utf8' ,
34- ) ;
35- const pkgJson = JSON . parse ( pkgJsonRaw ) ;
36-
37- return { location, entryPath, pkgJson } ;
38- } ;
39-
40- const install = async ( packageName : string ) => {
41- const __dirname = path . dirname ( new URL ( import . meta. url ) . pathname ) ;
42- await installPackage ( packageName , {
43- cwd : __dirname ,
44- packageManager : 'npm' ,
45- additionalArgs : [ '--force' ] ,
46- } ) ;
47-
48- const { pkgJson } = await getInfo ( packageName ) ;
49-
50- // Install whitelisted devDependencies
51- if ( pkgJson ?. hypermod ?. dependencies ) {
52- await Promise . all (
53- pkgJson . hypermod . dependencies . map ( ( dep : string ) => {
54- const version = pkgJson . devDependencies [ dep ] ;
55- if ( ! version ) return ;
56- return installPackage ( `${ dep } @${ version } ` , {
57- cwd : __dirname ,
58- packageManager : 'npm' ,
59- additionalArgs : [ '--force' ] ,
60- } ) ;
61- } ) ,
62- ) ;
63- }
64- } ;
65-
66- return {
67- install,
68- getInfo,
69- require : async ( packageName : string ) => import ( packageName ) ,
70- } ;
71- } ;
72-
7320export default async function main (
7421 paths : string [ ] ,
7522 flags : Partial < core . Flags > ,
@@ -100,10 +47,6 @@ export default async function main(
10047 } ;
10148 }
10249
103- const packageManager = flags . experimentalLoader
104- ? ExperimentalModuleLoader ( )
105- : new PluginManager ( pluginManagerConfig ) ;
106-
10750 let transforms : string [ ] = [ ] ;
10851
10952 if ( ! flags . transform && ! flags . packages ) {
@@ -254,11 +197,7 @@ export default async function main(
254197 . filter ( id => id . startsWith ( '#' ) )
255198 . map ( id => id . substring ( 1 ) ) ;
256199
257- const { community, remote } = await fetchPackages (
258- pkgName ,
259- // @ts -expect-error Experimental loader
260- packageManager ,
261- ) ;
200+ const { community, remote } = await fetchPackages ( pkgName ) ;
262201
263202 const config = mergeConfigs ( community , remote ) ;
264203
0 commit comments