File tree 1 file changed +8
-10
lines changed
1 file changed +8
-10
lines changed Original file line number Diff line number Diff line change 1
1
import fs from 'node:fs'
2
- import fsp from 'node:fs/promises'
3
2
import path from 'node:path'
4
3
import { pathToFileURL } from 'node:url'
5
4
import { promisify } from 'node:util'
@@ -1091,18 +1090,17 @@ async function loadConfigFromBundledFile(
1091
1090
) : Promise < UserConfigExport > {
1092
1091
// for esm, before we can register loaders without requiring users to run node
1093
1092
// with --experimental-loader themselves, we have to do a hack here:
1094
- // write it to disk , load it with native Node ESM, then delete the file .
1093
+ // convert to base64 , load it with native Node ESM.
1095
1094
if ( isESM ) {
1096
- const fileBase = `${ fileName } .timestamp-${ Date . now ( ) } -${ Math . random ( )
1097
- . toString ( 16 )
1098
- . slice ( 2 ) } `
1099
- const fileNameTmp = `${ fileBase } .mjs`
1100
- const fileUrl = `${ pathToFileURL ( fileBase ) } .mjs`
1101
- await fsp . writeFile ( fileNameTmp , bundledCode )
1102
1095
try {
1103
- return ( await dynamicImport ( fileUrl ) ) . default
1096
+ return (
1097
+ await dynamicImport (
1098
+ 'data:text/javascript;base64,' +
1099
+ Buffer . from ( bundledCode ) . toString ( 'base64' ) ,
1100
+ )
1101
+ ) . default
1104
1102
} finally {
1105
- fs . unlink ( fileNameTmp , ( ) => { } ) // Ignore errors
1103
+ // Ignore errors
1106
1104
}
1107
1105
}
1108
1106
// for cjs, we can register a custom loader via `_require.extensions`
You can’t perform that action at this time.
0 commit comments