create-cloudflare 2.0.2 → 2.0.3
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.
- package/package.json +1 -1
- package/dist/angular/templates/src/_routes.json +0 -5
- package/dist/angular/templates/src/main.server.ts +0 -35
- package/dist/angular/templates/tools/bundle.mjs +0 -74
- package/dist/angular/templates/tools/copy-client-files.mjs +0 -4
- package/dist/angular/templates/tools/copy-worker-files.mjs +0 -10
- package/dist/angular/templates/tools/paths.mjs +0 -9
- package/dist/angular/templates/tsconfig.server.json +0 -5
- package/dist/cli.js +0 -56580
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/templates/chatgptPlugin/ts/.assets/example.png +0 -0
- package/templates/chatgptPlugin/ts/README.md +0 -25
- package/templates/chatgptPlugin/ts/package-lock.json +0 -1971
- package/templates/chatgptPlugin/ts/package.json +0 -16
- package/templates/chatgptPlugin/ts/src/index.ts +0 -33
- package/templates/chatgptPlugin/ts/src/search.ts +0 -63
- package/templates/chatgptPlugin/ts/wrangler.toml +0 -3
- package/templates/common/js/.prettierrc +0 -5
- package/templates/common/js/package.json +0 -14
- package/templates/common/js/src/ab-test.js +0 -41
- package/templates/common/js/src/proxy.js +0 -23
- package/templates/common/js/src/redirect.js +0 -13
- package/templates/common/js/src/router.js +0 -22
- package/templates/common/js/src/worker.js +0 -46
- package/templates/common/js/wrangler.toml +0 -40
- package/templates/common/ts/.prettierrc +0 -5
- package/templates/common/ts/package.json +0 -15
- package/templates/common/ts/src/ab-test.ts +0 -41
- package/templates/common/ts/src/proxy.ts +0 -23
- package/templates/common/ts/src/redirect.ts +0 -13
- package/templates/common/ts/src/router.ts +0 -22
- package/templates/common/ts/src/worker.ts +0 -46
- package/templates/common/ts/tsconfig.json +0 -101
- package/templates/common/ts/worker-configuration.d.ts +0 -16
- package/templates/common/ts/wrangler.toml +0 -40
- package/templates/simple/js/.prettierrc +0 -5
- package/templates/simple/js/package.json +0 -14
- package/templates/simple/js/src/worker.js +0 -15
- package/templates/simple/js/wrangler.toml +0 -40
- package/templates/simple/ts/.prettierrc +0 -5
- package/templates/simple/ts/package.json +0 -14
- package/templates/simple/ts/src/worker.ts +0 -32
- package/templates/simple/ts/tsconfig.json +0 -101
- package/templates/simple/ts/wrangler.toml +0 -40
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import "zone.js/dist/zone-node";
|
|
2
|
-
import "@angular/platform-server/init";
|
|
3
|
-
|
|
4
|
-
import { bootstrapApplication } from "@angular/platform-browser";
|
|
5
|
-
import { renderApplication } from "@angular/platform-server";
|
|
6
|
-
|
|
7
|
-
import { AppComponent } from "./app/app.component";
|
|
8
|
-
import { config } from "./app/app.config.server";
|
|
9
|
-
|
|
10
|
-
interface Env {
|
|
11
|
-
ASSETS: { fetch: typeof fetch };
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// We attach the Cloudflare `fetch()` handler to the global scope
|
|
15
|
-
// so that we can export it when we process the Angular output.
|
|
16
|
-
// See tools/bundle.mjs
|
|
17
|
-
(globalThis as any).__workerFetchHandler = async function fetch(
|
|
18
|
-
request: Request,
|
|
19
|
-
env: Env
|
|
20
|
-
) {
|
|
21
|
-
const url = new URL(request.url);
|
|
22
|
-
console.log("render SSR", url.href);
|
|
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();
|
|
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);
|
|
35
|
-
};
|
|
@@ -1,74 +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
|
-
let main = result.outputFiles[0].text;
|
|
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 };";
|
|
49
|
-
|
|
50
|
-
await fs.writeFile(path.resolve(workerPath, "index.js"), main);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Use esbuild to process the lazy load modules
|
|
54
|
-
// In particular we need to convert the CommonJS export syntax to ESM.
|
|
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
|
-
});
|
|
67
|
-
|
|
68
|
-
let content = result.outputFiles[0].text;
|
|
69
|
-
|
|
70
|
-
// Export the fetch handler (grabbing it from the global).
|
|
71
|
-
content = "const exports = {};\n" + content + "\nexport default exports";
|
|
72
|
-
|
|
73
|
-
await fs.writeFile(path.resolve(workerPath, filePath), content);
|
|
74
|
-
}
|
|
@@ -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,9 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
4
|
-
const dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
|
-
export const root = path.resolve(dirname, "..");
|
|
6
|
-
export const client = path.resolve(root, "dist/browser");
|
|
7
|
-
export const ssr = path.resolve(root, "dist/server");
|
|
8
|
-
export const cloudflare = path.resolve(root, "dist/cloudflare");
|
|
9
|
-
export const worker = path.resolve(cloudflare, "_worker.js");
|