Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ You can configure additional options using `cloudflareDev: { }` in `nitro.config
- `configPath`: Sets a custom path for `wrangler.toml` file.
- `silent`: Hide initial banner.
- `environment`: Sets specific environment (useful for multi-environment configurations)
- `remoteBindings`: Enable Wrangler's experimental remoteBindings.

## Development

Expand Down
7 changes: 5 additions & 2 deletions examples/nitro/nitro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@ import nitroCloudflareBindings from "nitro-cloudflare-dev";

// https://nitro.unjs.io/config
export default defineNitroConfig({
modules: [nitroCloudflareBindings]
});
modules: [nitroCloudflareBindings],
// cloudflareDev: {
// remoteBindings: true
// }
});
5 changes: 5 additions & 0 deletions examples/nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,9 @@
export default defineNuxtConfig({
modules: ["nitro-cloudflare-dev"],
compatibilityDate: "2024-10-10",
// nitro: {
// cloudflareDev: {
// remoteBindings: true,
// },
// }
});
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ declare module "nitropack" {
environment?: string;
persistDir?: string;
silent?: boolean;
remoteBindings?: boolean;
};
}
}
Expand Down Expand Up @@ -65,7 +66,12 @@ async function nitroModule(nitro: Nitro) {
"",
`Config path: \`${configPath ? relative(".", configPath) : colorize("yellow", "cannot find `wrangler.json`, `wrangler.jsonc`, or `wrangler.toml`")}\``,
`Persist dir: \`${relative(".", persistDir)}\` ${addedToGitIgnore ? colorize("green", "(added to `.gitignore`)") : ""}`,
].join("\n"),
nitro.options.cloudflareDev?.remoteBindings
? `Remote bindings: ${colorize("green", "enabled")} (🧪 experimental)`
: undefined,
]
.filter((row) => row !== undefined)
.join("\n"),
);
}

Expand All @@ -75,6 +81,7 @@ async function nitroModule(nitro: Nitro) {
configPath,
persistDir,
environment: nitro.options.cloudflareDev?.environment,
remoteBindings: nitro.options.cloudflareDev?.remoteBindings,
};

// Make sure runtime is transpiled
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/plugin.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ async function _getPlatformProxy() {
configPath: string;
persistDir: string;
environment?: string;
remoteBindings?: boolean;
};
} = useRuntimeConfig();

const proxyOptions: GetPlatformProxyOptions = {
configPath: runtimeConfig.wrangler.configPath,
persist: { path: runtimeConfig.wrangler.persistDir },
...(runtimeConfig.wrangler.remoteBindings && {
experimental: { remoteBindings: true },
}),
};
// TODO: investigate why
// https://github.com/pi0/nitro-cloudflare-dev/issues/51
Expand Down