File tree Expand file tree Collapse file tree 5 files changed +32
-11
lines changed
templates/unstable-vite-cloudflare Expand file tree Collapse file tree 5 files changed +32
-11
lines changed Original file line number Diff line number Diff line change
1
+ This directory provides a temporary implementation of CloudFlare's [ ` getBindingsProxy ` API] [ get-bindings-proxy ] .
2
+
3
+ Once [ CloudFlare ships that feature] [ get-bindings-proxy ] , Remix will export a CloudFlare adapter that you can use:
4
+
5
+ ``` ts
6
+ // vite.config.ts
7
+ import { adapter as cloudflare } from " @remix-run/cloudflare" ;
8
+ import { vitePlugin as remix } from " @remix-run/dev" ;
9
+ import { defineConfig } from " vite" ;
10
+
11
+ export default defineConfig ({
12
+ plugins: [
13
+ remix ({
14
+ adapter: cloudflare ({
15
+ bindings: {
16
+ /* ... */
17
+ },
18
+ }),
19
+ }),
20
+ ],
21
+ });
22
+ ```
23
+
24
+ [ get-bindings-proxy ] : https://github.com/cloudflare/workers-sdk/pull/4523
Original file line number Diff line number Diff line change 1
- // Eventually, `getCloudflareDevBindings` will be replaced by the official `getBindingsProxy` API from CloudFlare
2
- // https://github.com/cloudflare/workers-sdk/pull/4523
3
- // At that point, Remix will absorb this adapter so you can import it directly in your `vite.config.ts`:
4
- //
5
- // import { adapter as cloudflare } from "@remix-run/cloudflare"
6
- //
7
- // Until then, this `.cloudflare/` directory provides the adapter implementation.
8
- import { DevBindingsOptions , getCloudflareDevBindings } from "./bindings" ;
1
+ import { DevBindingsOptions , getBindingsProxy } from "./bindings" ;
9
2
10
3
export const adapter =
11
4
( options ?: { bindings : DevBindingsOptions } ) => async ( ) => {
12
5
let bindings : Record < string , unknown > | undefined ;
13
6
if ( options ?. bindings ) {
14
- bindings = await getCloudflareDevBindings ( options . bindings ) ;
7
+ bindings = await getBindingsProxy ( options . bindings ) ;
15
8
}
16
9
let loadContext = bindings && { env : bindings } ;
17
10
return { loadContext } ;
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ export type DevBindingsOptions = {
20
20
persist ?: false | string ;
21
21
} ;
22
22
23
- export async function getCloudflareDevBindings ( options : DevBindingsOptions ) {
23
+ export async function getBindingsProxy ( options : DevBindingsOptions ) {
24
24
let mf = await instantiateMiniflare ( options ) ;
25
25
let bindings = await mf . getBindings ( ) ;
26
26
return bindings ;
Original file line number Diff line number Diff line change
1
+ // If you're wondering what this code is all about, check out the README.md in this directory!
2
+ export { adapter } from "./adapter" ;
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ import { unstable_vitePlugin as remix } from "@remix-run/dev";
2
2
import { defineConfig } from "vite" ;
3
3
import tsconfigPaths from "vite-tsconfig-paths" ;
4
4
5
- import { adapter as cloudflare } from "./.cloudflare/adapter" ;
5
+ // Check out .cloudflare/README.md for why there's a `.cloudflare` directory in this template
6
+ // In the future, you'll be able to import the `cloudflare` adapter from `@remix-run/cloudflare`
7
+ import { adapter as cloudflare } from "./.cloudflare" ;
6
8
7
9
export default defineConfig ( {
8
10
plugins : [
You can’t perform that action at this time.
0 commit comments