create-cloudflare 2.0.0-next.2 → 2.0.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.
Files changed (51) hide show
  1. package/README.md +9 -8
  2. package/dist/angular/templates/src/_routes.json +3 -3
  3. package/dist/angular/templates/src/main.server.ts +15 -15
  4. package/dist/angular/templates/tools/bundle.mjs +44 -44
  5. package/dist/angular/templates/tools/copy-worker-files.mjs +2 -2
  6. package/dist/angular/templates/tsconfig.server.json +2 -4
  7. package/dist/cli.js +5980 -17400
  8. package/dist/tsconfig.tsbuildinfo +1 -0
  9. package/package.json +18 -23
  10. package/templates/common/js/.prettierrc +5 -0
  11. package/templates/common/js/package.json +14 -0
  12. package/templates/common/js/src/ab-test.js +41 -0
  13. package/templates/common/js/src/proxy.js +23 -0
  14. package/templates/common/js/src/redirect.js +13 -0
  15. package/templates/{examples → common}/js/src/router.js +4 -8
  16. package/templates/common/js/src/worker.js +46 -0
  17. package/templates/common/js/wrangler.toml +40 -0
  18. package/templates/common/ts/.prettierrc +5 -0
  19. package/templates/common/ts/package.json +15 -0
  20. package/templates/common/ts/src/ab-test.ts +41 -0
  21. package/templates/common/ts/src/proxy.ts +23 -0
  22. package/templates/common/ts/src/redirect.ts +13 -0
  23. package/templates/{examples → common}/ts/src/router.ts +4 -8
  24. package/templates/common/ts/src/worker.ts +46 -0
  25. package/templates/{examples → common}/ts/tsconfig.json +2 -6
  26. package/templates/common/ts/worker-configuration.d.ts +16 -0
  27. package/templates/common/ts/wrangler.toml +40 -0
  28. package/templates/simple/js/.prettierrc +3 -3
  29. package/templates/simple/js/package.json +12 -12
  30. package/templates/simple/js/src/worker.js +3 -3
  31. package/templates/simple/js/wrangler.toml +37 -0
  32. package/templates/simple/ts/.prettierrc +3 -3
  33. package/templates/simple/ts/package.json +12 -12
  34. package/templates/simple/ts/src/worker.ts +17 -14
  35. package/templates/simple/ts/tsconfig.json +2 -6
  36. package/templates/simple/ts/wrangler.toml +37 -0
  37. package/templates/examples/js/.prettierrc +0 -5
  38. package/templates/examples/js/package.json +0 -14
  39. package/templates/examples/js/src/ab-test.js +0 -41
  40. package/templates/examples/js/src/proxy.js +0 -22
  41. package/templates/examples/js/src/redirect.js +0 -13
  42. package/templates/examples/js/src/worker.js +0 -37
  43. package/templates/examples/js/wrangler.toml +0 -7
  44. package/templates/examples/ts/.prettierrc +0 -5
  45. package/templates/examples/ts/package.json +0 -15
  46. package/templates/examples/ts/src/ab-test.ts +0 -41
  47. package/templates/examples/ts/src/proxy.ts +0 -22
  48. package/templates/examples/ts/src/redirect.ts +0 -13
  49. package/templates/examples/ts/src/worker.ts +0 -37
  50. package/templates/examples/ts/worker-configuration.d.ts +0 -13
  51. package/templates/examples/ts/wrangler.toml +0 -7
package/README.md CHANGED
@@ -1,15 +1,16 @@
1
1
  # create-cloudflare
2
2
 
3
- `create-cloudflare` is a scaffolding tool meant to help users get started with Cloudflare Pages using their framework of choice as quickly and easily as possible.
4
-
5
- Instead of having to choose from a set of pre-constructed templates, this tool allows you to run the creation commands of your desired framework directly. This means that you can configure it with all the options the
6
-
7
- To get started, run the following command:
3
+ A CLI for creating and deploying new applications to Cloudflare.
8
4
 
9
5
  ```bash
10
- npm create cloudflare
6
+ npm create cloudflare@latest
11
7
  # or
12
- yarn create cloudflare
8
+ pnpm create cloudflare@latest
13
9
  # or
14
- pnmp create cloudflare
10
+ yarn create cloudflare
15
11
  ```
12
+
13
+ ### Community
14
+
15
+ - Join us [on Discord](https://discord.gg/cloudflaredev)
16
+ - File an issue [on Github](https://github.com/cloudflare/workers-sdk/issues/new/choose)
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 1,
3
- "include": ["/*"],
4
- "exclude": ["/*.*"]
2
+ "version": 1,
3
+ "include": ["/*"],
4
+ "exclude": ["/*.*"]
5
5
  }
@@ -8,28 +8,28 @@ import { AppComponent } from "./app/app.component";
8
8
  import { config } from "./app/app.config.server";
9
9
 
10
10
  interface Env {
11
- ASSETS: { fetch: typeof fetch };
11
+ ASSETS: { fetch: typeof fetch };
12
12
  }
13
13
 
14
14
  // We attach the Cloudflare `fetch()` handler to the global scope
15
15
  // so that we can export it when we process the Angular output.
16
16
  // See tools/bundle.mjs
17
17
  (globalThis as any).__workerFetchHandler = async function fetch(
18
- request: Request,
19
- env: Env
18
+ request: Request,
19
+ env: Env
20
20
  ) {
21
- const url = new URL(request.url);
22
- console.log("render SSR", url.href);
21
+ const url = new URL(request.url);
22
+ console.log("render SSR", url.href);
23
23
 
24
- // Get the root `index.html` content.
25
- const indexUrl = new URL("/", url);
26
- const indexResponse = await env.ASSETS.fetch(new Request(indexUrl));
27
- const document = await indexResponse.text();
24
+ // Get the root `index.html` content.
25
+ const indexUrl = new URL("/", url);
26
+ const indexResponse = await env.ASSETS.fetch(new Request(indexUrl));
27
+ const document = await indexResponse.text();
28
28
 
29
- const content = await renderApplication(
30
- () => bootstrapApplication(AppComponent, config),
31
- { document, url: url.pathname }
32
- );
33
- // console.log("rendered SSR", content);
34
- return new Response(content, indexResponse);
29
+ const content = await renderApplication(
30
+ () => bootstrapApplication(AppComponent, config),
31
+ { document, url: url.pathname }
32
+ );
33
+ // console.log("rendered SSR", content);
34
+ return new Response(content, indexResponse);
35
35
  };
@@ -8,12 +8,12 @@ import fg from "fast-glob";
8
8
 
9
9
  // Process each of the JS files in the `_worker.js` directory
10
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
- }
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
17
  }
18
18
 
19
19
  // Use esbuild to process the main entry-point.
@@ -22,53 +22,53 @@ for (const entry of await fg("**/*.js", { cwd: workerPath, onlyFiles: true })) {
22
22
  // - convert dynamic `require()` calls to `await import()` calls
23
23
  // - ensure that the Cloudflare `fetch()` handler is exported
24
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
- });
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
39
 
40
- let main = result.outputFiles[0].text;
40
+ let main = result.outputFiles[0].text;
41
41
 
42
- // Patch any dynamic imports (converting `require()` calls to `import()` calls).
43
- main = main.replace(
44
- 'installChunk(__require("./" + __webpack_require__.u(chunkId))',
45
- 'promises.push(import("./" + __webpack_require__.u(chunkId)).then((mod) => installChunk(mod.default))'
46
- );
47
- // Export the fetch handler (grabbing it from the global).
48
- main += "\nexport default { fetch : globalThis.__workerFetchHandler };";
42
+ // Patch any dynamic imports (converting `require()` calls to `import()` calls).
43
+ main = main.replace(
44
+ 'installChunk(__require("./" + __webpack_require__.u(chunkId))',
45
+ 'promises.push(import("./" + __webpack_require__.u(chunkId)).then((mod) => installChunk(mod.default))'
46
+ );
47
+ // Export the fetch handler (grabbing it from the global).
48
+ main += "\nexport default { fetch : globalThis.__workerFetchHandler };";
49
49
 
50
- await fs.writeFile(path.resolve(workerPath, "index.js"), main);
50
+ await fs.writeFile(path.resolve(workerPath, "index.js"), main);
51
51
  }
52
52
 
53
53
  // Use esbuild to process the lazy load modules
54
54
  // In particular we need to convert the CommonJS export syntax to ESM.
55
55
  async function bundleLazyModule(filePath) {
56
- const result = await esbuild.build({
57
- entryPoints: [filePath],
58
- bundle: true,
59
- format: "cjs",
60
- write: false,
61
- absWorkingDir: workerPath,
62
- define: {
63
- global: "globalThis",
64
- },
65
- plugins: [NodeModulesPolyfillPlugin()],
66
- });
56
+ const result = await esbuild.build({
57
+ entryPoints: [filePath],
58
+ bundle: true,
59
+ format: "cjs",
60
+ write: false,
61
+ absWorkingDir: workerPath,
62
+ define: {
63
+ global: "globalThis",
64
+ },
65
+ plugins: [NodeModulesPolyfillPlugin()],
66
+ });
67
67
 
68
- let content = result.outputFiles[0].text;
68
+ let content = result.outputFiles[0].text;
69
69
 
70
- // Export the fetch handler (grabbing it from the global).
71
- content = "const exports = {};\n" + content + "\nexport default exports";
70
+ // Export the fetch handler (grabbing it from the global).
71
+ content = "const exports = {};\n" + content + "\nexport default exports";
72
72
 
73
- await fs.writeFile(path.resolve(workerPath, filePath), content);
73
+ await fs.writeFile(path.resolve(workerPath, filePath), content);
74
74
  }
@@ -5,6 +5,6 @@ import path from "node:path";
5
5
  import { ssr, worker } from "./paths.mjs";
6
6
  fs.cpSync(ssr, worker, { recursive: true });
7
7
  fs.renameSync(
8
- path.resolve(worker, "main.js"),
9
- path.resolve(worker, "index.js")
8
+ path.resolve(worker, "main.js"),
9
+ path.resolve(worker, "index.js")
10
10
  );
@@ -1,7 +1,5 @@
1
1
  /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
2
  {
3
- "extends": "./tsconfig.app.json",
4
- "files": [
5
- "./src/main.server.ts"
6
- ]
3
+ "extends": "./tsconfig.app.json",
4
+ "files": ["./src/main.server.ts"]
7
5
  }