create-cloudflare 2.6.2 → 2.7.1

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.
@@ -1,6 +1,6 @@
1
1
  name = "<TBD>"
2
2
  main = "src/index.ts"
3
- compatibility_date = "2023-05-15"
3
+ compatibility_date = "<TBD>"
4
4
 
5
5
  # Cron Triggers
6
6
  # Docs: https://developers.cloudflare.com/workers/platform/triggers/cron-triggers/
@@ -1,77 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { worker as workerPath } from "./paths.mjs";
4
- import * as esbuild from "esbuild";
5
- import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill";
6
- import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill";
7
- import fg from "fast-glob";
8
-
9
- // Process each of the JS files in the `_worker.js` directory
10
- for (const entry of await fg("**/*.js", { cwd: workerPath, onlyFiles: true })) {
11
- if (entry === "index.js") {
12
- // This is the main bundle and gets special treatment
13
- await bundleMain();
14
- } else {
15
- await bundleLazyModule(entry);
16
- }
17
- }
18
-
19
- // Use esbuild to process the main entry-point.
20
- // - shim Node.js APIs
21
- // - convert `global` to `globalThis`
22
- // - convert dynamic `require()` calls to `await import()` calls
23
- // - ensure that the Cloudflare `fetch()` handler is exported
24
- async function bundleMain() {
25
- const result = await esbuild.build({
26
- entryPoints: ["index.js"],
27
- bundle: true,
28
- format: "iife",
29
- write: false,
30
- absWorkingDir: workerPath,
31
- define: {
32
- global: "globalThis",
33
- },
34
- plugins: [
35
- NodeGlobalsPolyfillPlugin({ buffer: true }),
36
- NodeModulesPolyfillPlugin(),
37
- ],
38
- });
39
-
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;
42
-
43
- // Patch any dynamic imports (converting `require()` calls to `import()` calls).
44
- main = main.replace(
45
- 'installChunk(__require("./" + __webpack_require__.u(chunkId))',
46
- 'promises.push(import("./" + __webpack_require__.u(chunkId)).then((mod) => installChunk(mod.default))'
47
- );
48
- // Export the fetch handler (grabbing it from the global).
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)) };";
52
-
53
- await fs.writeFile(path.resolve(workerPath, "index.js"), main);
54
- }
55
-
56
- // Use esbuild to process the lazy load modules
57
- // In particular we need to convert the CommonJS export syntax to ESM.
58
- async function bundleLazyModule(filePath) {
59
- const result = await esbuild.build({
60
- entryPoints: [filePath],
61
- bundle: true,
62
- format: "cjs",
63
- write: false,
64
- absWorkingDir: workerPath,
65
- define: {
66
- global: "globalThis",
67
- },
68
- plugins: [NodeModulesPolyfillPlugin()],
69
- });
70
-
71
- let content = result.outputFiles[0].text;
72
-
73
- // Export the fetch handler (grabbing it from the global).
74
- content = "const exports = {};\n" + content + "\nexport default exports";
75
-
76
- await fs.writeFile(path.resolve(workerPath, filePath), content);
77
- }
@@ -1,4 +0,0 @@
1
- // Copy the client-side files over so that they can be uploaded by the pages publish command.
2
- import fs from "node:fs";
3
- import { client, cloudflare } from "./paths.mjs";
4
- fs.cpSync(client, cloudflare, { recursive: true });
@@ -1,10 +0,0 @@
1
- // Copy the lazy loaded modules into the dist folder so that they can be
2
- // uploaded along with the main Worker module.
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import { ssr, worker } from "./paths.mjs";
6
- fs.cpSync(ssr, worker, { recursive: true });
7
- fs.renameSync(
8
- path.resolve(worker, "main.js"),
9
- path.resolve(worker, "index.js")
10
- );
@@ -1,5 +0,0 @@
1
- /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
- {
3
- "extends": "./tsconfig.app.json",
4
- "files": ["./src/main.server.ts"]
5
- }