File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -23,14 +23,20 @@ export function nonWebpackRequire(): RequireFn {
23
23
return ;
24
24
}
25
25
26
- const loaderCode = data ?. toString ( ) || "" ;
27
26
// Only custom esm loader is supported.
28
- // Use `import(base64code)` to load ESM
29
- const dataUrl = `data:text/javascript;base64,${ btoa ( loaderCode ) } ` ;
27
+ const loaderCode = data ?. toString ( ) || "" ;
28
+ const codeUrl = URL . createObjectURL (
29
+ new Blob ( [ loaderCode ] , { type : "text/javascript" } )
30
+ ) ;
30
31
try {
31
32
// biome-ignore lint/security/noGlobalEval: use `eval("import")` rather than `import` to suppress the warning in @rspack/browser
32
- const modulePromise = eval ( `import("${ dataUrl } ")` ) ;
33
- modulePromise . then ( resolve ) ;
33
+ const modulePromise = eval (
34
+ `import("${ codeUrl } ")`
35
+ ) as Promise < unknown > ;
36
+ modulePromise . then ( module => {
37
+ URL . revokeObjectURL ( codeUrl ) ;
38
+ resolve ( module ) ;
39
+ } ) ;
34
40
} catch ( e ) {
35
41
reject ( e ) ;
36
42
}
You can’t perform that action at this time.
0 commit comments