File tree Expand file tree Collapse file tree 3 files changed +11
-20
lines changed Expand file tree Collapse file tree 3 files changed +11
-20
lines changed Original file line number Diff line number Diff line change @@ -15,9 +15,13 @@ const DotnetSupportLib = {
15
15
__dotnet_replacements);
16
16
17
17
// here we replace things which are not exposed in another way
18
- __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
18
+ scriptDirectory = __dotnet_replacements.scriptDirectory;
19
19
readAsync = __dotnet_replacements.readAsync;
20
- var fetch = __dotnet_replacements.fetch;` ,
20
+ var fetch = __dotnet_replacements.fetch;
21
+ if (ENVIRONMENT_IS_NODE) {
22
+ __dirname = __dotnet_replacements.scriptDirectory;
23
+ }
24
+ ` ,
21
25
} ;
22
26
23
27
// the methods would be visible to EMCC linker
Original file line number Diff line number Diff line change @@ -15,12 +15,13 @@ const DotnetSupportLib = {
15
15
__dotnet_replacements);
16
16
17
17
// here we replace things which are not exposed in another way
18
- __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
18
+ scriptDirectory = __dotnet_replacements.scriptDirectory;
19
19
readAsync = __dotnet_replacements.readAsync;
20
20
var fetch = __dotnet_replacements.fetch;
21
21
22
22
// here we replace things which are broken on NodeJS for ES6
23
23
if (ENVIRONMENT_IS_NODE) {
24
+ __dirname = __dotnet_replacements.scriptDirectory;
24
25
getBinaryPromise = async () => {
25
26
if (!wasmBinary) {
26
27
try {
Original file line number Diff line number Diff line change @@ -22,9 +22,6 @@ const originalConsole = {
22
22
error : console . error
23
23
} ;
24
24
25
- let isXUnitDoneCheck = false ;
26
- let isXmlDoneCheck = false ;
27
-
28
25
function proxyMethod ( prefix , func , asJson ) {
29
26
return function ( ) {
30
27
const args = [ ...arguments ] ;
@@ -369,20 +366,9 @@ async function loadDotnet(file) {
369
366
} ;
370
367
} else if ( is_browser ) { // vanila JS in browser
371
368
loadScript = async function ( file ) {
372
- const script = document . createElement ( "script" ) ;
373
- script . src = file ;
374
- document . head . appendChild ( script ) ;
375
- let timeout = 100 ;
376
- // bysy spin waiting for script to load into global namespace
377
- while ( timeout > 0 ) {
378
- if ( globalThis . createDotnetRuntime ) {
379
- return globalThis . createDotnetRuntime ;
380
- }
381
- // delay 10ms
382
- await new Promise ( resolve => setTimeout ( resolve , 10 ) ) ;
383
- timeout -- ;
384
- }
385
- throw new Error ( "Can't load " + file ) ;
369
+ globalThis . exports = { } ; // if we are loading cjs file
370
+ const createDotnetRuntime = await import ( file ) ;
371
+ return typeof createDotnetRuntime === "function" ? createDotnetRuntime : globalThis . exports . createDotnetRuntime ;
386
372
}
387
373
}
388
374
else if ( typeof globalThis . load !== 'undefined' ) {
You can’t perform that action at this time.
0 commit comments