Cheng Shao pushed to branch wip/wasm-fix-serviceworker at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • changelog.d/wasm-fix-serviceworker
    1
    +section: wasm-backend
    
    2
    +synopsis: Ensure post-linker output is synchronous ESM and fix loading in ServiceWorker
    
    3
    +issues: #27257
    
    4
    +mrs: !16093

  • utils/jsffi/prelude.mjs
    ... ... @@ -39,19 +39,13 @@ export class JSValManager {
    39 39
     // To benchmark different setImmediate() implementations in the
    
    40 40
     // browser, use https://github.com/jphpsf/setImmediate-shim-demo as a
    
    41 41
     // starting point.
    
    42
    -export const setImmediate = await (async () => {
    
    43
    -  // node, bun, or other scripts might have set this up in the browser
    
    42
    +export const setImmediate = (() => {
    
    43
    +  // node, deno, bun, or other scripts might have set this up in the
    
    44
    +  // browser
    
    44 45
       if (globalThis.setImmediate) {
    
    45 46
         return globalThis.setImmediate;
    
    46 47
       }
    
    47 48
     
    
    48
    -  // deno
    
    49
    -  if (globalThis.Deno) {
    
    50
    -    try {
    
    51
    -      return (await import("node:timers")).setImmediate;
    
    52
    -    } catch {}
    
    53
    -  }
    
    54
    -
    
    55 49
       // https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask
    
    56 50
       if (globalThis.scheduler) {
    
    57 51
         return (cb, ...args) => scheduler.postTask(() => cb(...args));