@@ -925,20 +925,22 @@ export async function loadConfigFromFile(
925
925
let userConfig : UserConfigExport | undefined
926
926
927
927
if ( isESM ) {
928
- const fileUrl = require ( 'url' ) . pathToFileURL ( resolvedPath )
929
928
const bundled = await bundleConfigFile ( resolvedPath , true )
930
929
dependencies = bundled . dependencies
931
930
if ( isTS ) {
932
931
// before we can register loaders without requiring users to run node
933
932
// with --experimental-loader themselves, we have to do a hack here:
934
933
// bundle the config file w/ ts transforms first, write it to disk,
935
934
// load it with native Node ESM, then delete the file.
936
- fs . writeFileSync ( resolvedPath + '.js' , bundled . code )
937
- userConfig = ( await dynamicImport ( `${ fileUrl } .js?t=${ Date . now ( ) } ` ) )
938
- . default
939
- fs . unlinkSync ( resolvedPath + '.js' )
935
+ const fileBase = `${ resolvedPath } .timestamp-${ Date . now ( ) } `
936
+ const fileNameTmp = `${ fileBase } .js`
937
+ const fileUrl = `${ require ( 'url' ) . pathToFileURL ( fileBase ) } .js`
938
+ fs . writeFileSync ( fileNameTmp , bundled . code )
939
+ userConfig = ( await dynamicImport ( fileUrl ) ) . default
940
+ fs . unlinkSync ( fileNameTmp )
940
941
debug ( `TS + native esm config loaded in ${ getTime ( ) } ` , fileUrl )
941
942
} else {
943
+ const fileUrl = require ( 'url' ) . pathToFileURL ( resolvedPath )
942
944
// using Function to avoid this from being compiled away by TS/Rollup
943
945
// append a query so that we force reload fresh config in case of
944
946
// server restart
0 commit comments