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 = {
1515 __dotnet_replacements);
1616
1717 // here we replace things which are not exposed in another way
18- __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
18+ scriptDirectory = __dotnet_replacements.scriptDirectory;
1919 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+ ` ,
2125} ;
2226
2327// the methods would be visible to EMCC linker
Original file line number Diff line number Diff line change @@ -15,12 +15,13 @@ const DotnetSupportLib = {
1515 __dotnet_replacements);
1616
1717 // here we replace things which are not exposed in another way
18- __dirname = scriptDirectory = __dotnet_replacements.scriptDirectory;
18+ scriptDirectory = __dotnet_replacements.scriptDirectory;
1919 readAsync = __dotnet_replacements.readAsync;
2020 var fetch = __dotnet_replacements.fetch;
2121
2222 // here we replace things which are broken on NodeJS for ES6
2323 if (ENVIRONMENT_IS_NODE) {
24+ __dirname = __dotnet_replacements.scriptDirectory;
2425 getBinaryPromise = async () => {
2526 if (!wasmBinary) {
2627 try {
Original file line number Diff line number Diff line change @@ -22,9 +22,6 @@ const originalConsole = {
2222 error : console . error
2323} ;
2424
25- let isXUnitDoneCheck = false ;
26- let isXmlDoneCheck = false ;
27-
2825function proxyMethod ( prefix , func , asJson ) {
2926 return function ( ) {
3027 const args = [ ...arguments ] ;
@@ -369,20 +366,9 @@ async function loadDotnet(file) {
369366 } ;
370367 } else if ( is_browser ) { // vanila JS in browser
371368 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 ;
386372 }
387373 }
388374 else if ( typeof globalThis . load !== 'undefined' ) {
You can’t perform that action at this time.
0 commit comments