File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -1141,18 +1141,17 @@ async function loadConfigFromBundledFile(
11411141) : Promise < UserConfigExport > {
11421142 // for esm, before we can register loaders without requiring users to run node
11431143 // with --experimental-loader themselves, we have to do a hack here:
1144- // write it to disk , load it with native Node ESM, then delete the file .
1144+ // convert to base64 , load it with native Node ESM.
11451145 if ( isESM ) {
1146- const fileBase = `${ fileName } .timestamp-${ Date . now ( ) } -${ Math . random ( )
1147- . toString ( 16 )
1148- . slice ( 2 ) } `
1149- const fileNameTmp = `${ fileBase } .mjs`
1150- const fileUrl = `${ pathToFileURL ( fileBase ) } .mjs`
1151- await fsp . writeFile ( fileNameTmp , bundledCode )
11521146 try {
1153- return ( await dynamicImport ( fileUrl ) ) . default
1154- } finally {
1155- fs . unlink ( fileNameTmp , ( ) => { } ) // Ignore errors
1147+ return (
1148+ await dynamicImport (
1149+ 'data:text/javascript;base64,' +
1150+ Buffer . from ( bundledCode ) . toString ( 'base64' ) ,
1151+ )
1152+ ) . default
1153+ } catch ( e ) {
1154+ throw new Error ( `${ e . message } at ${ fileName } ` )
11561155 }
11571156 }
11581157 // for cjs, we can register a custom loader via `_require.extensions`
You can’t perform that action at this time.
0 commit comments