@@ -3,7 +3,6 @@ import type { LoadConfigOptions, LoadConfigResult, LoadConfigSource } from './ty
33import { createRequire } from 'node:module'
44import { basename , dirname , join } from 'node:path'
55import process from 'node:process'
6- import { pathToFileURL } from 'node:url'
76import { toArray } from '@antfu/utils'
87import { readFile , unlink , writeFile } from '@quansync/fs'
98import defu from 'defu'
@@ -33,43 +32,30 @@ const loadConfigFile = quansync(async <T>(
3332 return code
3433 } )
3534
36- const builtinTS = process . features . typescript || process . versions . bun || process . versions . deno
3735 const importModule = quansync ( {
3836 sync : ( ) => {
39- if ( builtinTS ) {
40- const defaultImport = require ( bundleFilepath )
41- config = interopDefault ( defaultImport )
42- }
43- else {
44- const { createJiti } = require ( 'jiti' ) as typeof import ( 'jiti' )
45- const jiti = createJiti ( import . meta. url , {
46- fsCache : false ,
47- moduleCache : false ,
48- interopDefault : true ,
49- } )
50- config = interopDefault ( jiti ( bundleFilepath ) )
51- dependencies = Object . values ( jiti . cache )
52- . map ( i => i . filename )
53- . filter ( Boolean )
54- }
37+ const { createJiti } = require ( 'jiti' ) as typeof import ( 'jiti' )
38+ const jiti = createJiti ( import . meta. url , {
39+ fsCache : false ,
40+ moduleCache : false ,
41+ interopDefault : true ,
42+ } )
43+ config = interopDefault ( jiti ( bundleFilepath ) )
44+ dependencies = Object . values ( jiti . cache )
45+ . map ( i => i . filename )
46+ . filter ( Boolean )
5547 } ,
5648 async : async ( ) => {
57- if ( builtinTS ) {
58- const defaultImport = await import ( pathToFileURL ( bundleFilepath ) . href )
59- config = interopDefault ( defaultImport )
60- }
61- else {
62- const { createJiti } = await import ( 'jiti' )
63- const jiti = createJiti ( import . meta. url , {
64- fsCache : false ,
65- moduleCache : false ,
66- interopDefault : true ,
67- } )
68- config = interopDefault ( await jiti . import ( bundleFilepath , { default : true } ) )
69- dependencies = Object . values ( jiti . cache )
70- . map ( i => i . filename )
71- . filter ( Boolean )
72- }
49+ const { createJiti } = await import ( 'jiti' )
50+ const jiti = createJiti ( import . meta. url , {
51+ fsCache : false ,
52+ moduleCache : false ,
53+ interopDefault : true ,
54+ } )
55+ config = interopDefault ( await jiti . import ( bundleFilepath , { default : true } ) )
56+ dependencies = Object . values ( jiti . cache )
57+ . map ( i => i . filename )
58+ . filter ( Boolean )
7359 } ,
7460 } )
7561
0 commit comments