create-cloudflare 2.0.10 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,7 +37,8 @@ async function bundleMain() {
37
37
  ],
38
38
  });
39
39
 
40
- let main = result.outputFiles[0].text;
40
+ // Store the original promise (before Angular/Zone.js replaces it) on the global scope.
41
+ let main = "globalThis.OGPromise = Promise;\n" + result.outputFiles[0].text;
41
42
 
42
43
  // Patch any dynamic imports (converting `require()` calls to `import()` calls).
43
44
  main = main.replace(
@@ -45,7 +46,9 @@ async function bundleMain() {
45
46
  'promises.push(import("./" + __webpack_require__.u(chunkId)).then((mod) => installChunk(mod.default))'
46
47
  );
47
48
  // Export the fetch handler (grabbing it from the global).
48
- main += "\nexport default { fetch : globalThis.__workerFetchHandler };";
49
+ // Also Cloudflare expects `fetch()` to return an original Promise (not a ZoneAwarePromise).
50
+ main +=
51
+ "\nexport default { fetch: (request, env) => globalThis.OGPromise.resolve(globalThis.__workerFetchHandler(request, env)) };";
49
52
 
50
53
  await fs.writeFile(path.resolve(workerPath, "index.js"), main);
51
54
  }