alchemy 0.56.0 → 0.57.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.
- package/bin/alchemy.js +14223 -14180
- package/bin/commands/create.ts +15 -17
- package/bin/commands/deploy.ts +3 -3
- package/bin/commands/destroy.ts +3 -3
- package/bin/commands/dev.ts +3 -4
- package/bin/commands/init.ts +9 -9
- package/bin/commands/login.ts +6 -6
- package/bin/commands/run.ts +3 -4
- package/bin/constants.ts +1 -1
- package/bin/services/execute-alchemy.ts +4 -6
- package/bin/trpc.ts +49 -0
- package/lib/apply.d.ts.map +1 -1
- package/lib/apply.js +3 -4
- package/lib/apply.js.map +1 -1
- package/lib/cloudflare/assets.js +5 -4
- package/lib/cloudflare/assets.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/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/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/miniflare-controller.d.ts.map +1 -1
- package/lib/cloudflare/miniflare/miniflare-controller.js +2 -1
- package/lib/cloudflare/miniflare/miniflare-controller.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/{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/{local-dev-cloudflare-shim.d.ts → tanstack-start/plugin.d.ts} +3 -2
- package/lib/cloudflare/tanstack-start/plugin.d.ts.map +1 -0
- package/lib/cloudflare/{local-dev-cloudflare-shim.js → tanstack-start/plugin.js} +6 -9
- 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 +1 -1
- package/lib/cloudflare/worker-bundle.d.ts.map +1 -1
- package/lib/cloudflare/worker-bundle.js +23 -13
- 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 +5 -124
- 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/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 +0 -1
- package/lib/scope.d.ts.map +1 -1
- package/lib/scope.js +1 -2
- 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 +44 -6
- package/src/apply.ts +3 -7
- package/src/cloudflare/assets.ts +7 -4
- package/src/cloudflare/{astro.ts → astro/astro.ts} +46 -29
- package/src/cloudflare/astro/plugin.ts +11 -0
- package/src/cloudflare/cloudflare-env-proxy.ts +50 -0
- package/src/cloudflare/compatibility-date.gen.ts +1 -1
- package/src/cloudflare/d1-local-migrations.ts +1 -1
- package/src/cloudflare/index.ts +8 -8
- package/src/cloudflare/miniflare/miniflare-controller.ts +2 -1
- package/src/cloudflare/miniflare/paths.ts +52 -0
- 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/{local-dev-cloudflare-shim.ts → tanstack-start/plugin.ts} +8 -9
- 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 +27 -13
- package/src/cloudflare/worker-stub.ts +11 -14
- package/src/cloudflare/worker.ts +8 -155
- package/src/cloudflare/wrangler.json.ts +32 -4
- 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 +1 -3
- 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/astro/package.json +1 -1
- package/templates/nuxt/alchemy.run.ts +1 -3
- package/templates/nuxt/nuxt.config.ts +4 -5
- package/templates/nuxt/package.json +1 -2
- 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 +1 -3
- package/templates/rwsdk/vite.config.mts +2 -2
- package/templates/sveltekit/alchemy.run.ts +1 -3
- package/templates/sveltekit/package.json +1 -1
- package/templates/sveltekit/svelte.config.js +2 -2
- package/templates/tanstack-start/package.json +1 -1
- package/templates/tanstack-start/vite.config.ts +2 -2
- package/templates/typescript/package.json +1 -1
- package/templates/vite/alchemy.run.ts +1 -1
- package/templates/vite/package.json +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.map +0 -1
- package/lib/cloudflare/local-dev-cloudflare-shim.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/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
|
@@ -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
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { GetPlatformProxyOptions } from "wrangler";
|
|
2
|
+
import { dedent } from "../../util/dedent.ts";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* TanStackStart server functions and middleware run in Node.js intead of Miniflare when using `vite dev`.
|
|
@@ -7,7 +8,7 @@ import { dedent } from "../util/dedent.ts";
|
|
|
7
8
|
*
|
|
8
9
|
* @see https://developers.cloudflare.com/workers/framework-guides/web-apps/tanstack/#using-cloudflare-bindings
|
|
9
10
|
*/
|
|
10
|
-
export function
|
|
11
|
+
export default function alchemy(options: GetPlatformProxyOptions = {}) {
|
|
11
12
|
return {
|
|
12
13
|
name: "cloudflare-workers-dev-shim",
|
|
13
14
|
apply: "serve", // dev‑only
|
|
@@ -17,14 +18,12 @@ export function cloudflareWorkersDevEnvironmentShim() {
|
|
|
17
18
|
},
|
|
18
19
|
load(id: string) {
|
|
19
20
|
if (id === "cloudflare:workers") {
|
|
20
|
-
const processEnv = JSON.stringify(process.env);
|
|
21
|
-
|
|
22
|
-
// @see https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy
|
|
23
21
|
return dedent`
|
|
24
|
-
import {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
import { getCloudflareEnvProxy } from "alchemy/cloudflare";
|
|
23
|
+
export const env = await getCloudflareEnvProxy(${JSON.stringify(
|
|
24
|
+
options,
|
|
25
|
+
)});
|
|
26
|
+
`;
|
|
28
27
|
}
|
|
29
28
|
},
|
|
30
29
|
} as const;
|
|
@@ -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
|
+
}
|