alchemy 0.55.3 → 0.57.0
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/bin/alchemy.js +14245 -14406
- package/bin/commands/create.ts +7 -7
- package/bin/commands/deploy.ts +2 -2
- package/bin/commands/destroy.ts +2 -2
- package/bin/commands/dev.ts +2 -2
- package/bin/commands/init.ts +6 -6
- package/bin/commands/login.ts +3 -3
- package/bin/commands/run.ts +2 -2
- package/bin/services/execute-alchemy.ts +3 -3
- package/bin/trpc.ts +49 -0
- package/lib/alchemy.d.ts.map +1 -1
- package/lib/alchemy.js +7 -0
- package/lib/alchemy.js.map +1 -1
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +3 -4
- package/lib/apply.js.map +1 -1
- package/lib/cloudflare/{astro.d.ts → astro/astro.d.ts} +6 -5
- package/lib/cloudflare/astro/astro.d.ts.map +1 -0
- package/lib/cloudflare/astro/astro.js +91 -0
- package/lib/cloudflare/astro/astro.js.map +1 -0
- package/lib/cloudflare/astro/plugin.d.ts +4 -0
- package/lib/cloudflare/astro/plugin.d.ts.map +1 -0
- package/lib/cloudflare/astro/plugin.js +10 -0
- package/lib/cloudflare/astro/plugin.js.map +1 -0
- package/lib/cloudflare/bundle/plugin-hot-reload.d.ts +1 -3
- package/lib/cloudflare/bundle/plugin-hot-reload.d.ts.map +1 -1
- package/lib/cloudflare/bundle/plugin-hot-reload.js +4 -1
- package/lib/cloudflare/bundle/plugin-hot-reload.js.map +1 -1
- package/lib/cloudflare/cloudflare-env-proxy.d.ts +4 -0
- package/lib/cloudflare/cloudflare-env-proxy.d.ts.map +1 -0
- package/lib/cloudflare/cloudflare-env-proxy.js +34 -0
- package/lib/cloudflare/cloudflare-env-proxy.js.map +1 -0
- package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
- package/lib/cloudflare/compatibility-date.gen.js +1 -1
- package/lib/cloudflare/compatibility-presets.d.ts +1 -1
- package/lib/cloudflare/compatibility-presets.js +1 -1
- package/lib/cloudflare/compatibility-presets.js.map +1 -1
- package/lib/cloudflare/d1-local-migrations.js +1 -1
- package/lib/cloudflare/d1-local-migrations.js.map +1 -1
- package/lib/cloudflare/index.d.ts +8 -8
- package/lib/cloudflare/index.d.ts.map +1 -1
- package/lib/cloudflare/index.js +8 -8
- package/lib/cloudflare/index.js.map +1 -1
- package/lib/cloudflare/miniflare/build-worker-options.d.ts +22 -0
- package/lib/cloudflare/miniflare/build-worker-options.d.ts.map +1 -0
- package/lib/cloudflare/miniflare/build-worker-options.js +394 -0
- package/lib/cloudflare/miniflare/build-worker-options.js.map +1 -0
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts +23 -0
- package/lib/cloudflare/miniflare/miniflare-controller.d.ts.map +1 -0
- package/lib/cloudflare/miniflare/miniflare-controller.js +111 -0
- package/lib/cloudflare/miniflare/miniflare-controller.js.map +1 -0
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +5 -15
- package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -1
- package/lib/cloudflare/miniflare/paths.d.ts +5 -0
- package/lib/cloudflare/miniflare/paths.d.ts.map +1 -0
- package/lib/cloudflare/miniflare/paths.js +35 -0
- package/lib/cloudflare/miniflare/paths.js.map +1 -0
- package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts +1 -5
- package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/remote-binding-proxy.js +17 -22
- package/lib/cloudflare/miniflare/remote-binding-proxy.js.map +1 -1
- package/lib/cloudflare/{nuxt.d.ts → nuxt/nuxt.d.ts} +4 -4
- package/lib/cloudflare/nuxt/nuxt.d.ts.map +1 -0
- package/lib/cloudflare/{nuxt.js → nuxt/nuxt.js} +8 -13
- package/lib/cloudflare/nuxt/nuxt.js.map +1 -0
- package/lib/cloudflare/nuxt/plugin.d.ts +4 -0
- package/lib/cloudflare/nuxt/plugin.d.ts.map +1 -0
- package/lib/cloudflare/nuxt/plugin.js +14 -0
- package/lib/cloudflare/nuxt/plugin.js.map +1 -0
- package/lib/cloudflare/oauth.js +2 -2
- package/lib/cloudflare/oauth.js.map +1 -1
- package/lib/cloudflare/orange.d.ts +3 -3
- package/lib/cloudflare/orange.d.ts.map +1 -1
- package/lib/cloudflare/orange.js +11 -21
- package/lib/cloudflare/orange.js.map +1 -1
- package/lib/cloudflare/react-router/plugin.d.ts +4 -0
- package/lib/cloudflare/react-router/plugin.d.ts.map +1 -0
- package/lib/cloudflare/react-router/plugin.js +11 -0
- package/lib/cloudflare/react-router/plugin.js.map +1 -0
- package/lib/cloudflare/react-router/react-router.d.ts +17 -0
- package/lib/cloudflare/react-router/react-router.d.ts.map +1 -0
- package/lib/cloudflare/react-router/react-router.js +21 -0
- package/lib/cloudflare/react-router/react-router.js.map +1 -0
- package/lib/cloudflare/redwood/plugin.d.ts +4 -0
- package/lib/cloudflare/redwood/plugin.d.ts.map +1 -0
- package/lib/cloudflare/redwood/plugin.js +19 -0
- package/lib/cloudflare/redwood/plugin.js.map +1 -0
- package/lib/cloudflare/{redwood.d.ts → redwood/redwood.d.ts} +5 -5
- package/lib/cloudflare/redwood/redwood.d.ts.map +1 -0
- package/lib/cloudflare/{redwood.js → redwood/redwood.js} +12 -13
- package/lib/cloudflare/redwood/redwood.js.map +1 -0
- package/lib/cloudflare/sveltekit/plugin.d.ts +4 -0
- package/lib/cloudflare/sveltekit/plugin.d.ts.map +1 -0
- package/lib/cloudflare/sveltekit/plugin.js +11 -0
- package/lib/cloudflare/sveltekit/plugin.js.map +1 -0
- package/lib/cloudflare/{sveltekit.d.ts → sveltekit/sveltekit.d.ts} +5 -5
- package/lib/cloudflare/sveltekit/sveltekit.d.ts.map +1 -0
- package/lib/cloudflare/{sveltekit.js → sveltekit/sveltekit.js} +4 -4
- package/lib/cloudflare/sveltekit/sveltekit.js.map +1 -0
- package/lib/cloudflare/tanstack-start/plugin.d.ts +16 -0
- package/lib/cloudflare/tanstack-start/plugin.d.ts.map +1 -0
- package/lib/cloudflare/tanstack-start/plugin.js +28 -0
- package/lib/cloudflare/tanstack-start/plugin.js.map +1 -0
- package/lib/cloudflare/{tanstack-start.d.ts → tanstack-start/tanstack-start.d.ts} +5 -5
- package/lib/cloudflare/tanstack-start/tanstack-start.d.ts.map +1 -0
- package/lib/cloudflare/tanstack-start/tanstack-start.js +11 -0
- package/lib/cloudflare/tanstack-start/tanstack-start.js.map +1 -0
- package/lib/cloudflare/vite/plugin.d.ts +4 -0
- package/lib/cloudflare/vite/plugin.d.ts.map +1 -0
- package/lib/cloudflare/vite/plugin.js +23 -0
- package/lib/cloudflare/vite/plugin.js.map +1 -0
- package/lib/cloudflare/{vite.d.ts → vite/vite.d.ts} +4 -4
- package/lib/cloudflare/vite/vite.d.ts.map +1 -0
- package/lib/cloudflare/vite/vite.js +19 -0
- package/lib/cloudflare/vite/vite.js.map +1 -0
- package/lib/cloudflare/website.d.ts +92 -70
- package/lib/cloudflare/website.d.ts.map +1 -1
- package/lib/cloudflare/website.js +225 -94
- package/lib/cloudflare/website.js.map +1 -1
- package/lib/cloudflare/worker-bundle.d.ts +3 -1
- package/lib/cloudflare/worker-bundle.d.ts.map +1 -1
- package/lib/cloudflare/worker-bundle.js +42 -16
- package/lib/cloudflare/worker-bundle.js.map +1 -1
- package/lib/cloudflare/worker-stub.d.ts.map +1 -1
- package/lib/cloudflare/worker-stub.js +3 -6
- package/lib/cloudflare/worker-stub.js.map +1 -1
- package/lib/cloudflare/worker.d.ts +2 -7
- package/lib/cloudflare/worker.d.ts.map +1 -1
- package/lib/cloudflare/worker.js +17 -157
- package/lib/cloudflare/worker.js.map +1 -1
- package/lib/cloudflare/wrangler.json.d.ts +6 -0
- package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
- package/lib/cloudflare/wrangler.json.js +23 -6
- package/lib/cloudflare/wrangler.json.js.map +1 -1
- package/lib/context.d.ts +11 -0
- package/lib/context.d.ts.map +1 -1
- package/lib/context.js +8 -0
- package/lib/context.js.map +1 -1
- package/lib/env.d.ts +2 -2
- package/lib/env.d.ts.map +1 -1
- package/lib/env.js +5 -6
- package/lib/env.js.map +1 -1
- package/lib/random/index.d.ts +2 -0
- package/lib/random/index.d.ts.map +1 -0
- package/lib/random/index.js +2 -0
- package/lib/random/index.js.map +1 -0
- package/lib/random/random-string.d.ts +87 -0
- package/lib/random/random-string.d.ts.map +1 -0
- package/lib/random/random-string.js +72 -0
- package/lib/random/random-string.js.map +1 -0
- package/lib/runtime/bind.d.ts +1 -1
- package/lib/runtime/bind.d.ts.map +1 -1
- package/lib/runtime/bind.js.map +1 -1
- package/lib/scope.d.ts +11 -0
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +24 -0
- package/lib/scope.js.map +1 -1
- package/lib/secret.d.ts +2 -2
- package/lib/secret.d.ts.map +1 -1
- package/lib/secret.js +2 -2
- package/lib/secret.js.map +1 -1
- package/lib/state/cloudflare-state-store.js +1 -1
- package/lib/state/cloudflare-state-store.js.map +1 -1
- package/lib/state/dofs-state-store/index.js +1 -1
- package/lib/state/dofs-state-store/index.js.map +1 -1
- package/lib/util/detect-package-manager.d.ts +1 -0
- package/lib/util/detect-package-manager.d.ts.map +1 -1
- package/lib/util/detect-package-manager.js +10 -0
- package/lib/util/detect-package-manager.js.map +1 -1
- package/lib/util/telemetry/client.d.ts +1 -1
- package/lib/util/telemetry/client.d.ts.map +1 -1
- package/lib/util/telemetry/client.js +22 -1
- package/lib/util/telemetry/client.js.map +1 -1
- package/lib/util/telemetry/constants.d.ts.map +1 -1
- package/lib/util/telemetry/constants.js +2 -3
- package/lib/util/telemetry/constants.js.map +1 -1
- package/lib/util/telemetry/context.d.ts +1 -1
- package/lib/util/telemetry/context.d.ts.map +1 -1
- package/lib/util/telemetry/types.d.ts +7 -3
- package/lib/util/telemetry/types.d.ts.map +1 -1
- package/lib/vercel/api.d.ts.map +1 -1
- package/lib/vercel/api.js +1 -1
- package/lib/vercel/api.js.map +1 -1
- package/package.json +43 -4
- package/src/alchemy.ts +7 -0
- package/src/apply.ts +3 -7
- package/src/cloudflare/{astro.ts → astro/astro.ts} +46 -29
- package/src/cloudflare/astro/plugin.ts +11 -0
- package/src/cloudflare/bundle/plugin-hot-reload.ts +4 -3
- package/src/cloudflare/cloudflare-env-proxy.ts +50 -0
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/compatibility-presets.ts +1 -1
- package/src/cloudflare/d1-local-migrations.ts +1 -1
- package/src/cloudflare/index.ts +8 -8
- package/src/cloudflare/miniflare/build-worker-options.ts +454 -0
- package/src/cloudflare/miniflare/miniflare-controller.ts +129 -0
- package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +6 -15
- package/src/cloudflare/miniflare/paths.ts +52 -0
- package/src/cloudflare/miniflare/remote-binding-proxy.ts +18 -23
- package/src/cloudflare/{nuxt.ts → nuxt/nuxt.ts} +11 -16
- package/src/cloudflare/nuxt/plugin.ts +18 -0
- package/src/cloudflare/oauth.ts +2 -2
- package/src/cloudflare/orange.ts +13 -23
- package/src/cloudflare/react-router/plugin.ts +13 -0
- package/src/cloudflare/react-router/react-router.ts +41 -0
- package/src/cloudflare/redwood/plugin.ts +20 -0
- package/src/cloudflare/{redwood.ts → redwood/redwood.ts} +16 -19
- package/src/cloudflare/sveltekit/plugin.ts +12 -0
- package/src/cloudflare/{sveltekit.ts → sveltekit/sveltekit.ts} +9 -8
- package/src/cloudflare/tanstack-start/plugin.ts +30 -0
- package/src/cloudflare/tanstack-start/tanstack-start.ts +24 -0
- package/src/cloudflare/vite/plugin.ts +30 -0
- package/src/cloudflare/vite/vite.ts +34 -0
- package/src/cloudflare/website.ts +379 -204
- package/src/cloudflare/worker-bundle.ts +55 -16
- package/src/cloudflare/worker-stub.ts +11 -14
- package/src/cloudflare/worker.ts +23 -205
- package/src/cloudflare/wrangler.json.ts +32 -4
- package/src/context.ts +19 -0
- package/src/env.ts +8 -9
- package/src/random/index.ts +1 -0
- package/src/random/random-string.ts +126 -0
- package/src/runtime/bind.ts +2 -2
- package/src/scope.ts +25 -0
- package/src/secret.ts +4 -8
- package/src/state/cloudflare-state-store.ts +2 -2
- package/src/state/dofs-state-store/index.ts +1 -1
- package/src/util/detect-package-manager.ts +11 -0
- package/src/util/telemetry/client.ts +25 -2
- package/src/util/telemetry/constants.ts +2 -4
- package/src/util/telemetry/context.ts +1 -1
- package/src/util/telemetry/types.ts +8 -2
- package/src/vercel/api.ts +2 -4
- package/templates/astro/alchemy.run.ts +1 -3
- package/templates/astro/astro.config.mjs +2 -2
- package/templates/nuxt/alchemy.run.ts +1 -3
- package/templates/nuxt/nuxt.config.ts +4 -5
- package/templates/nuxt/package.json +0 -1
- package/templates/react-router/alchemy.run.ts +1 -4
- package/templates/react-router/vite.config.ts +2 -2
- package/templates/rwsdk/alchemy.run.ts +0 -1
- package/templates/rwsdk/package.json +0 -2
- package/templates/rwsdk/vite.config.mts +2 -2
- package/templates/sveltekit/alchemy.run.ts +1 -3
- package/templates/sveltekit/svelte.config.js +2 -2
- package/templates/tanstack-start/vite.config.ts +2 -2
- package/templates/vite/alchemy.run.ts +1 -1
- package/templates/vite/vite.config.ts +4 -5
- package/workers/cloudflare-state-store.js +12 -14
- package/lib/cloudflare/astro.d.ts.map +0 -1
- package/lib/cloudflare/astro.js +0 -69
- package/lib/cloudflare/astro.js.map +0 -1
- package/lib/cloudflare/local-dev-cloudflare-shim.d.ts +0 -13
- package/lib/cloudflare/local-dev-cloudflare-shim.d.ts.map +0 -1
- package/lib/cloudflare/local-dev-cloudflare-shim.js +0 -26
- package/lib/cloudflare/local-dev-cloudflare-shim.js.map +0 -1
- package/lib/cloudflare/miniflare/miniflare-worker-options.d.ts +0 -14
- package/lib/cloudflare/miniflare/miniflare-worker-options.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/miniflare-worker-options.js +0 -468
- package/lib/cloudflare/miniflare/miniflare-worker-options.js.map +0 -1
- package/lib/cloudflare/miniflare/miniflare.d.ts +0 -40
- package/lib/cloudflare/miniflare/miniflare.d.ts.map +0 -1
- package/lib/cloudflare/miniflare/miniflare.js +0 -142
- package/lib/cloudflare/miniflare/miniflare.js.map +0 -1
- package/lib/cloudflare/nuxt.d.ts.map +0 -1
- package/lib/cloudflare/nuxt.js.map +0 -1
- package/lib/cloudflare/react-router.d.ts +0 -17
- package/lib/cloudflare/react-router.d.ts.map +0 -1
- package/lib/cloudflare/react-router.js +0 -35
- package/lib/cloudflare/react-router.js.map +0 -1
- package/lib/cloudflare/redwood.d.ts.map +0 -1
- package/lib/cloudflare/redwood.js.map +0 -1
- package/lib/cloudflare/sveltekit.d.ts.map +0 -1
- package/lib/cloudflare/sveltekit.js.map +0 -1
- package/lib/cloudflare/tanstack-start.d.ts.map +0 -1
- package/lib/cloudflare/tanstack-start.js +0 -21
- package/lib/cloudflare/tanstack-start.js.map +0 -1
- package/lib/cloudflare/vite.d.ts.map +0 -1
- package/lib/cloudflare/vite.js +0 -20
- package/lib/cloudflare/vite.js.map +0 -1
- package/src/cloudflare/local-dev-cloudflare-shim.ts +0 -25
- package/src/cloudflare/miniflare/miniflare-worker-options.ts +0 -599
- package/src/cloudflare/miniflare/miniflare.ts +0 -183
- package/src/cloudflare/react-router.ts +0 -56
- package/src/cloudflare/tanstack-start.ts +0 -35
- package/src/cloudflare/vite.ts +0 -35
- package/templates/react-router/wrangler.jsonc +0 -6
- package/templates/rwsdk/wrangler.jsonc +0 -31
- package/templates/sveltekit/wrangler.jsonc +0 -7
- package/templates/tanstack-start/wrangler.jsonc +0 -7
- package/templates/typescript/index.ts +0 -1
- package/templates/vite/wrangler.jsonc +0 -6
|
@@ -32,7 +32,7 @@ export interface RemoteBindingProxy {
|
|
|
32
32
|
export async function createRemoteProxyWorker(input: {
|
|
33
33
|
name: string;
|
|
34
34
|
bindings: WorkerBindingSpec[];
|
|
35
|
-
}) {
|
|
35
|
+
}): Promise<RemoteBindingProxy> {
|
|
36
36
|
const api = await createCloudflareApi();
|
|
37
37
|
const script = await getInternalWorkerBundle("remote-binding-proxy");
|
|
38
38
|
const [token, subdomain] = await Promise.all([
|
|
@@ -42,9 +42,7 @@ export async function createRemoteProxyWorker(input: {
|
|
|
42
42
|
main_module: script.bundle.entrypoint,
|
|
43
43
|
compatibility_date: "2025-06-16",
|
|
44
44
|
bindings: input.bindings,
|
|
45
|
-
observability: {
|
|
46
|
-
enabled: false,
|
|
47
|
-
},
|
|
45
|
+
observability: { enabled: false },
|
|
48
46
|
},
|
|
49
47
|
bundle: script.bundle,
|
|
50
48
|
session: {
|
|
@@ -55,27 +53,24 @@ export async function createRemoteProxyWorker(input: {
|
|
|
55
53
|
import("../worker-subdomain.ts").then((m) => m.getAccountSubdomain(api)),
|
|
56
54
|
]);
|
|
57
55
|
|
|
58
|
-
const proxyURL =
|
|
56
|
+
const proxyURL = `https://${input.name}.${subdomain}.workers.dev`;
|
|
59
57
|
const server = new HTTPServer({
|
|
60
58
|
fetch: async (req) => {
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
url.search = origin.search;
|
|
64
|
-
url.hash = origin.hash;
|
|
59
|
+
const url = new URL(req.url);
|
|
60
|
+
const targetUrl = new URL(url.pathname + url.search, proxyURL);
|
|
65
61
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
const headers = new Headers(req.headers);
|
|
63
|
+
headers.set("cf-workers-preview-token", token);
|
|
64
|
+
headers.set("host", new URL(proxyURL).hostname);
|
|
65
|
+
headers.delete("cf-connecting-ip");
|
|
70
66
|
|
|
71
|
-
const res = await fetch(
|
|
67
|
+
const res = await fetch(targetUrl, {
|
|
72
68
|
method: req.method,
|
|
73
|
-
headers
|
|
69
|
+
headers,
|
|
74
70
|
body: req.body,
|
|
75
71
|
redirect: "manual",
|
|
76
72
|
});
|
|
77
73
|
|
|
78
|
-
// Remove headers that are not supported by miniflare
|
|
79
74
|
const responseHeaders = new Headers(res.headers);
|
|
80
75
|
responseHeaders.delete("transfer-encoding");
|
|
81
76
|
responseHeaders.delete("content-encoding");
|
|
@@ -86,6 +81,7 @@ export async function createRemoteProxyWorker(input: {
|
|
|
86
81
|
});
|
|
87
82
|
},
|
|
88
83
|
});
|
|
84
|
+
|
|
89
85
|
await server.listen();
|
|
90
86
|
return {
|
|
91
87
|
server,
|
|
@@ -126,13 +122,12 @@ async function createWorkersPreviewToken(
|
|
|
126
122
|
}
|
|
127
123
|
|
|
128
124
|
async function prewarm(url: string, previewToken: string) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
"cf-workers-preview-token": previewToken,
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
console.error(`Failed to prewarm worker: ${res.status} ${res.statusText}`);
|
|
125
|
+
try {
|
|
126
|
+
await fetch(url, {
|
|
127
|
+
headers: { "cf-workers-preview-token": previewToken },
|
|
128
|
+
});
|
|
129
|
+
} catch {
|
|
130
|
+
// Ignore prewarm errors
|
|
136
131
|
}
|
|
137
132
|
}
|
|
138
133
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
5
|
-
import type
|
|
2
|
+
import { getPackageManagerRunner } from "../../util/detect-package-manager.ts";
|
|
3
|
+
import type { Assets } from "../assets.ts";
|
|
4
|
+
import type { Bindings } from "../bindings.ts";
|
|
5
|
+
import { Website, type WebsiteProps } from "../website.ts";
|
|
6
|
+
import type { Worker } from "../worker.ts";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Properties for creating a Nuxt resource.
|
|
@@ -50,22 +51,16 @@ export async function Nuxt<B extends Bindings>(
|
|
|
50
51
|
id: string,
|
|
51
52
|
props?: Partial<NuxtProps<B>>,
|
|
52
53
|
): Promise<Nuxt<B>> {
|
|
53
|
-
|
|
54
|
-
return Website(id, {
|
|
54
|
+
const runner = await getPackageManagerRunner();
|
|
55
|
+
return await Website(id, {
|
|
55
56
|
...props,
|
|
56
57
|
noBundle: props?.noBundle ?? true,
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
build: props?.build ?? `${runner} nuxt build`,
|
|
59
|
+
dev: props?.dev ?? `${runner} nuxt dev`,
|
|
60
|
+
compatibility: "node",
|
|
59
61
|
// Default entry point for cloudflare-module preset
|
|
60
|
-
|
|
62
|
+
entrypoint: props?.entrypoint ?? "./.output/server/index.mjs",
|
|
61
63
|
// Default static assets directory for cloudflare-module preset
|
|
62
64
|
assets: props?.assets ?? path.join(".output", "public"),
|
|
63
|
-
// Ensure nodejs_compat flag is included for Nuxt compatibility
|
|
64
|
-
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
65
|
-
// Enable wrangler by default, common for Nuxt/Cloudflare deployments
|
|
66
|
-
wrangler: props?.wrangler ?? true,
|
|
67
|
-
dev: props?.dev ?? {
|
|
68
|
-
command: "nuxt dev",
|
|
69
|
-
},
|
|
70
65
|
});
|
|
71
66
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CloudflareOptions } from "nitropack/presets/cloudflare/types";
|
|
2
|
+
import { validateConfigPath, validatePersistPath } from "../miniflare/paths.ts";
|
|
3
|
+
|
|
4
|
+
const alchemy = (
|
|
5
|
+
options: Partial<CloudflareOptions> = {},
|
|
6
|
+
): CloudflareOptions => {
|
|
7
|
+
return {
|
|
8
|
+
nodeCompat: true,
|
|
9
|
+
dev: {
|
|
10
|
+
configPath: validateConfigPath(options.dev?.configPath),
|
|
11
|
+
persistDir: validatePersistPath(options.dev?.persistDir),
|
|
12
|
+
...options.dev,
|
|
13
|
+
},
|
|
14
|
+
...options,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default alchemy;
|
package/src/cloudflare/oauth.ts
CHANGED
|
@@ -6,7 +6,7 @@ import fs from "node:fs/promises";
|
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import open from "open";
|
|
9
|
-
import
|
|
9
|
+
import envPaths from "env-paths";
|
|
10
10
|
import { HTTPServer } from "../util/http.ts";
|
|
11
11
|
import { memoize } from "../util/memoize.ts";
|
|
12
12
|
import {
|
|
@@ -70,7 +70,7 @@ export const getRefreshedWranglerConfig = singleFlight(() =>
|
|
|
70
70
|
);
|
|
71
71
|
|
|
72
72
|
const getWranglerConfigPath = memoize(async () => {
|
|
73
|
-
const xdgConfigDir =
|
|
73
|
+
const xdgConfigDir = envPaths(".wrangler", { suffix: "" }).config;
|
|
74
74
|
const legacyConfigDir = path.join(os.homedir(), ".wrangler");
|
|
75
75
|
const configDir = (await fs
|
|
76
76
|
.stat(legacyConfigDir)
|
package/src/cloudflare/orange.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Assets } from "./assets.js";
|
|
2
2
|
import type { Bindings } from "./bindings.js";
|
|
3
|
-
import {
|
|
4
|
-
import type { Worker } from "./worker.
|
|
3
|
+
import { Vite, type ViteProps } from "./vite/vite.ts";
|
|
4
|
+
import type { Worker } from "./worker.ts";
|
|
5
5
|
|
|
6
|
-
export interface OrangeProps<B extends Bindings> extends
|
|
6
|
+
export interface OrangeProps<B extends Bindings> extends ViteProps<B> {}
|
|
7
7
|
|
|
8
8
|
// don't allow the ASSETS to be overriden
|
|
9
9
|
export type Orange<B extends Bindings> = B extends { ASSETS: any }
|
|
@@ -36,29 +36,19 @@ export type Orange<B extends Bindings> = B extends { ASSETS: any }
|
|
|
36
36
|
*/
|
|
37
37
|
export async function Orange<B extends Bindings>(
|
|
38
38
|
id: string,
|
|
39
|
-
props
|
|
39
|
+
props: Partial<OrangeProps<B>> = {},
|
|
40
40
|
): Promise<Orange<B>> {
|
|
41
|
-
return
|
|
41
|
+
return await Vite(id, {
|
|
42
42
|
...props,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// output since we don't resolve vite imports.
|
|
50
|
-
wrangler: props?.wrangler ?? {
|
|
43
|
+
noBundle: props.noBundle ?? true,
|
|
44
|
+
entrypoint: props.entrypoint ?? "dist/ssr/entry.server.js",
|
|
45
|
+
assets: props.assets ?? "dist/client",
|
|
46
|
+
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
47
|
+
wrangler: {
|
|
48
|
+
path: "wrangler.jsonc",
|
|
51
49
|
main: "app/entry.server.ts",
|
|
50
|
+
secrets: false,
|
|
51
|
+
...props.wrangler,
|
|
52
52
|
},
|
|
53
|
-
// Since we've already bundled the application with the build command, we can just
|
|
54
|
-
// upload the modules in the `dist/srr` directory. With `noBundle: true`, any files
|
|
55
|
-
// that match `**/*.js`, `**/*.mjs`, and `**/*.wasm` under the entrypoint's directory
|
|
56
|
-
// (which is `dist/ssr`) will be uploaded to the worker so we don't need any explicit
|
|
57
|
-
// module rules.
|
|
58
|
-
noBundle: true,
|
|
59
|
-
// `main` is used as the entrypoint in the Worker resource.
|
|
60
|
-
main: props?.main ?? "dist/ssr/entry.server.js",
|
|
61
|
-
assets: props?.assets ?? "dist/client",
|
|
62
|
-
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
63
53
|
});
|
|
64
54
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PluginConfig } from "@cloudflare/vite-plugin";
|
|
2
|
+
import alchemyVite from "../vite/plugin.ts";
|
|
3
|
+
|
|
4
|
+
const alchemy = (config?: PluginConfig) => {
|
|
5
|
+
return alchemyVite({
|
|
6
|
+
...config,
|
|
7
|
+
viteEnvironment: {
|
|
8
|
+
name: "ssr",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default alchemy;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getPackageManagerRunner } from "../../util/detect-package-manager.ts";
|
|
2
|
+
import type { Assets } from "../assets.ts";
|
|
3
|
+
import type { Bindings } from "../bindings.ts";
|
|
4
|
+
import { Vite, type ViteProps } from "../vite/vite.ts";
|
|
5
|
+
import type { Worker } from "../worker.ts";
|
|
6
|
+
|
|
7
|
+
export interface ReactRouterProps<B extends Bindings> extends ViteProps<B> {
|
|
8
|
+
/**
|
|
9
|
+
* @default workers/app.ts
|
|
10
|
+
*/
|
|
11
|
+
main?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// don't allow the ASSETS to be overriden
|
|
15
|
+
export type ReactRouter<B extends Bindings> = B extends { ASSETS: any }
|
|
16
|
+
? never
|
|
17
|
+
: Worker<B & { ASSETS: Assets }>;
|
|
18
|
+
|
|
19
|
+
export async function ReactRouter<B extends Bindings>(
|
|
20
|
+
id: string,
|
|
21
|
+
props: ReactRouterProps<B> = {},
|
|
22
|
+
): Promise<ReactRouter<B>> {
|
|
23
|
+
const runner = await getPackageManagerRunner();
|
|
24
|
+
return await Vite(id, {
|
|
25
|
+
...props,
|
|
26
|
+
build:
|
|
27
|
+
props.build ??
|
|
28
|
+
`${runner} react-router typegen && ${runner} react-router build`,
|
|
29
|
+
dev:
|
|
30
|
+
props.dev ??
|
|
31
|
+
`${runner} react-router typegen && ${runner} react-router dev`,
|
|
32
|
+
compatibility: "node",
|
|
33
|
+
entrypoint: props.entrypoint ?? "build/server/index.js",
|
|
34
|
+
noBundle: props.noBundle ?? true,
|
|
35
|
+
assets: props.assets ?? "build/client",
|
|
36
|
+
wrangler: {
|
|
37
|
+
main: props.wrangler?.main ?? props.main ?? "workers/app.ts",
|
|
38
|
+
transform: props.wrangler?.transform,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { redwood, type RedwoodPluginOptions } from "rwsdk/vite";
|
|
2
|
+
import { DEFAULT_CONFIG_PATH } from "../miniflare/paths.ts";
|
|
3
|
+
import alchemyVite from "../vite/plugin.ts";
|
|
4
|
+
|
|
5
|
+
const alchemyRedwood = (options?: RedwoodPluginOptions) => {
|
|
6
|
+
const configPath = options?.configPath ?? DEFAULT_CONFIG_PATH;
|
|
7
|
+
return [
|
|
8
|
+
redwood({
|
|
9
|
+
...options,
|
|
10
|
+
configPath,
|
|
11
|
+
includeCloudflarePlugin: false,
|
|
12
|
+
}),
|
|
13
|
+
alchemyVite({
|
|
14
|
+
configPath,
|
|
15
|
+
viteEnvironment: { name: "worker" },
|
|
16
|
+
}),
|
|
17
|
+
];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default alchemyRedwood;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import type { Assets } from "
|
|
3
|
-
import type { Bindings } from "
|
|
4
|
-
import {
|
|
5
|
-
import type { Worker } from "
|
|
2
|
+
import type { Assets } from "../assets.ts";
|
|
3
|
+
import type { Bindings } from "../bindings.ts";
|
|
4
|
+
import { Vite, type ViteProps } from "../vite/vite.ts";
|
|
5
|
+
import type { Worker } from "../worker.ts";
|
|
6
6
|
|
|
7
|
-
export interface RedwoodProps<B extends Bindings> extends
|
|
7
|
+
export interface RedwoodProps<B extends Bindings> extends ViteProps<B> {}
|
|
8
8
|
|
|
9
9
|
// don't allow the ASSETS to be overridden
|
|
10
10
|
export type Redwood<B extends Bindings> = B extends { ASSETS: any }
|
|
@@ -41,24 +41,21 @@ export async function Redwood<B extends Bindings>(
|
|
|
41
41
|
id: string,
|
|
42
42
|
props?: Partial<RedwoodProps<B>>,
|
|
43
43
|
): Promise<Redwood<B>> {
|
|
44
|
-
return
|
|
44
|
+
return await Vite(id, {
|
|
45
45
|
...props,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
build: props?.build ?? {
|
|
47
|
+
command: "rm -rf ./node_modules/.vite && vite build",
|
|
48
|
+
env: {
|
|
49
|
+
RWSDK_DEPLOY: "1",
|
|
50
|
+
},
|
|
51
51
|
},
|
|
52
52
|
noBundle: props?.noBundle ?? true,
|
|
53
|
-
|
|
54
|
-
props?.wrangler === false
|
|
55
|
-
? false
|
|
56
|
-
: {
|
|
57
|
-
main: props?.main ?? path.join("src", "worker.tsx"),
|
|
58
|
-
},
|
|
59
|
-
main: props?.main ?? path.join("dist", "worker", "worker.js"),
|
|
60
|
-
assets: props?.assets ?? path.join("dist", "client"),
|
|
53
|
+
entrypoint: props?.entrypoint ?? path.join("dist", "worker", "worker.js"),
|
|
61
54
|
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
62
55
|
compatibilityDate: props?.compatibilityDate ?? "2025-04-02",
|
|
56
|
+
wrangler: {
|
|
57
|
+
main: props?.wrangler?.main ?? "src/worker.tsx",
|
|
58
|
+
transform: props?.wrangler?.transform,
|
|
59
|
+
},
|
|
63
60
|
});
|
|
64
61
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import adapter, { type AdapterOptions } from "@sveltejs/adapter-cloudflare";
|
|
2
|
+
import { getPlatformProxyOptions } from "../cloudflare-env-proxy.ts";
|
|
3
|
+
|
|
4
|
+
const alchemy = (options?: AdapterOptions) => {
|
|
5
|
+
const platformProxy = getPlatformProxyOptions(options?.platformProxy);
|
|
6
|
+
return adapter({
|
|
7
|
+
platformProxy,
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default alchemy;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import type { Assets } from "
|
|
3
|
-
import type { Bindings } from "
|
|
4
|
-
import {
|
|
5
|
-
import type { Worker } from "
|
|
2
|
+
import type { Assets } from "../assets.ts";
|
|
3
|
+
import type { Bindings } from "../bindings.ts";
|
|
4
|
+
import { Vite, type ViteProps } from "../vite/vite.ts";
|
|
5
|
+
import type { Worker } from "../worker.ts";
|
|
6
6
|
|
|
7
|
-
export interface SvelteKitProps<B extends Bindings> extends
|
|
7
|
+
export interface SvelteKitProps<B extends Bindings> extends ViteProps<B> {}
|
|
8
8
|
|
|
9
9
|
// don't allow the ASSETS to be overriden
|
|
10
10
|
export type SvelteKit<B extends Bindings> = B extends { ASSETS: any }
|
|
@@ -61,12 +61,13 @@ export async function SvelteKit<B extends Bindings>(
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
return
|
|
64
|
+
return await Vite(id, {
|
|
65
65
|
...props,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
entrypoint:
|
|
67
|
+
props?.entrypoint ?? join(".svelte-kit", "cloudflare", "_worker.js"),
|
|
68
68
|
assets: props?.assets ?? join(".svelte-kit", "cloudflare"),
|
|
69
69
|
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
70
70
|
compatibilityDate: props?.compatibilityDate,
|
|
71
|
+
wrangler: { secrets: true },
|
|
71
72
|
});
|
|
72
73
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { GetPlatformProxyOptions } from "wrangler";
|
|
2
|
+
import { dedent } from "../../util/dedent.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TanStackStart server functions and middleware run in Node.js intead of Miniflare when using `vite dev`.
|
|
6
|
+
*
|
|
7
|
+
* This plugin polyfills the cloudflare:workers module & includes `process.env` during the dev server phase.
|
|
8
|
+
*
|
|
9
|
+
* @see https://developers.cloudflare.com/workers/framework-guides/web-apps/tanstack/#using-cloudflare-bindings
|
|
10
|
+
*/
|
|
11
|
+
export default function alchemy(options: GetPlatformProxyOptions = {}) {
|
|
12
|
+
return {
|
|
13
|
+
name: "cloudflare-workers-dev-shim",
|
|
14
|
+
apply: "serve", // dev‑only
|
|
15
|
+
enforce: "pre",
|
|
16
|
+
resolveId(id: string) {
|
|
17
|
+
if (id === "cloudflare:workers") return id; // tell Vite we handled it
|
|
18
|
+
},
|
|
19
|
+
load(id: string) {
|
|
20
|
+
if (id === "cloudflare:workers") {
|
|
21
|
+
return dedent`
|
|
22
|
+
import { getCloudflareEnvProxy } from "alchemy/cloudflare";
|
|
23
|
+
export const env = await getCloudflareEnvProxy(${JSON.stringify(
|
|
24
|
+
options,
|
|
25
|
+
)});
|
|
26
|
+
`;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
} as const;
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Assets } from "../assets.ts";
|
|
2
|
+
import type { Bindings } from "../bindings.ts";
|
|
3
|
+
import { Vite, type ViteProps } from "../vite/vite.ts";
|
|
4
|
+
import type { Worker } from "../worker.ts";
|
|
5
|
+
|
|
6
|
+
export interface TanStackStartProps<B extends Bindings> extends ViteProps<B> {}
|
|
7
|
+
|
|
8
|
+
// don't allow the ASSETS to be overriden
|
|
9
|
+
export type TanStackStart<B extends Bindings> = B extends { ASSETS: any }
|
|
10
|
+
? never
|
|
11
|
+
: Worker<B & { ASSETS: Assets }>;
|
|
12
|
+
|
|
13
|
+
export async function TanStackStart<B extends Bindings>(
|
|
14
|
+
id: string,
|
|
15
|
+
props?: Partial<TanStackStartProps<B>>,
|
|
16
|
+
): Promise<TanStackStart<B>> {
|
|
17
|
+
return await Vite(id, {
|
|
18
|
+
...props,
|
|
19
|
+
noBundle: true,
|
|
20
|
+
entrypoint: props?.entrypoint ?? ".output/server/index.mjs",
|
|
21
|
+
compatibilityFlags: ["nodejs_compat", ...(props?.compatibilityFlags ?? [])],
|
|
22
|
+
assets: props?.assets ?? ".output/public",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cloudflare, type PluginConfig } from "@cloudflare/vite-plugin";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_PERSIST_PATH,
|
|
5
|
+
validateConfigPath,
|
|
6
|
+
validatePersistPath,
|
|
7
|
+
} from "../miniflare/paths.ts";
|
|
8
|
+
|
|
9
|
+
const alchemy = (config?: PluginConfig) => {
|
|
10
|
+
const persistState = config?.persistState ?? {
|
|
11
|
+
path: validatePersistPath(
|
|
12
|
+
typeof config?.persistState === "object"
|
|
13
|
+
? config.persistState.path
|
|
14
|
+
: DEFAULT_PERSIST_PATH,
|
|
15
|
+
),
|
|
16
|
+
};
|
|
17
|
+
if (typeof persistState === "object" && persistState.path.endsWith("v3")) {
|
|
18
|
+
persistState.path = path.dirname(persistState.path);
|
|
19
|
+
}
|
|
20
|
+
return cloudflare({
|
|
21
|
+
...config,
|
|
22
|
+
configPath: validateConfigPath(config?.configPath),
|
|
23
|
+
persistState,
|
|
24
|
+
experimental: config?.experimental ?? {
|
|
25
|
+
remoteBindings: true,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default alchemy;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { getPackageManagerRunner } from "../../util/detect-package-manager.ts";
|
|
2
|
+
import type { Assets } from "../assets.ts";
|
|
3
|
+
import type { Bindings } from "../bindings.ts";
|
|
4
|
+
import { Website, type WebsiteProps } from "../website.ts";
|
|
5
|
+
import type { Worker } from "../worker.ts";
|
|
6
|
+
|
|
7
|
+
export interface ViteProps<B extends Bindings>
|
|
8
|
+
extends Omit<WebsiteProps<B>, "spa"> {}
|
|
9
|
+
|
|
10
|
+
export type Vite<B extends Bindings> = B extends { ASSETS: any }
|
|
11
|
+
? never
|
|
12
|
+
: Worker<B & { ASSETS: Assets }>;
|
|
13
|
+
|
|
14
|
+
export async function Vite<B extends Bindings>(
|
|
15
|
+
id: string,
|
|
16
|
+
props: ViteProps<B>,
|
|
17
|
+
): Promise<Vite<B>> {
|
|
18
|
+
const runner = await getPackageManagerRunner();
|
|
19
|
+
return await Website(id, {
|
|
20
|
+
...props,
|
|
21
|
+
spa: true,
|
|
22
|
+
assets:
|
|
23
|
+
typeof props.assets === "string"
|
|
24
|
+
? { directory: props.assets }
|
|
25
|
+
: {
|
|
26
|
+
...(props.assets ?? {}),
|
|
27
|
+
directory:
|
|
28
|
+
props.assets?.directory ??
|
|
29
|
+
(props.entrypoint || props.script ? "dist/client" : "dist"),
|
|
30
|
+
},
|
|
31
|
+
build: props.build ?? `${runner} vite build`,
|
|
32
|
+
dev: props.dev ?? `${runner} vite dev`,
|
|
33
|
+
});
|
|
34
|
+
}
|