rsbuild-plugin-cloudflare 0.0.1 → 0.0.2
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/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# `rsbuild-plugin-cloudflare`
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/rsbuild-plugin-cloudflare)
|
|
4
|
+
|
|
3
5
|
An experimental [Rsbuild](https://rsbuild.rs) plugin for Cloudflare Workers. It
|
|
4
6
|
runs your Workers in workerd during `rsbuild dev` and `rsbuild preview`, and
|
|
5
7
|
builds them, with your client assets, during `rsbuild build` into a Cloudflare
|
|
@@ -53,7 +55,10 @@ To change how a Worker is built, configure its environment in Rsbuild's
|
|
|
53
55
|
precedence, apart from `source.entry`, `output.target` and `output.module`,
|
|
54
56
|
which the plugin always sets so that the Worker runs in workerd, and
|
|
55
57
|
`output.distPath.root`, which it sets to the Worker's Build Output location, as
|
|
56
|
-
the Vite plugin does.
|
|
58
|
+
the Vite plugin does. The Worker's entry keeps the
|
|
59
|
+
[layer](https://rspack.rs/config/entry#entrydescriptionlayer) of the entries
|
|
60
|
+
that it replaces, if they're all in the same one (e.g. TanStack Start's server
|
|
61
|
+
entry, with React Server Components).
|
|
57
62
|
|
|
58
63
|
```ts
|
|
59
64
|
export default defineConfig({
|
|
@@ -106,6 +111,12 @@ Rsbuild (e.g. one created from TanStack's Rsbuild template) on Workers:
|
|
|
106
111
|
});
|
|
107
112
|
```
|
|
108
113
|
|
|
114
|
+
If the app has its own
|
|
115
|
+
[server entry](https://tanstack.com/start/latest/docs/framework/react/guide/server-entry-point)
|
|
116
|
+
(e.g. `src/server.ts`), make that the entrypoint instead (e.g.
|
|
117
|
+
`entrypoint: "./src/server.ts"`). The Worker runs its entrypoint, so with
|
|
118
|
+
TanStack Start's it would bypass the app's.
|
|
119
|
+
|
|
109
120
|
3. Add `cloudflare()` before `tanstackStart()`, with `rsbuildEnvironment.name`
|
|
110
121
|
set to TanStack Start's server environment, `ssr`. This is required: without
|
|
111
122
|
it, the plugin builds the entrypoint in its own `cloudflare` environment,
|
|
@@ -158,6 +169,12 @@ const getGreeting = createServerFn().handler(() => env.GREETING);
|
|
|
158
169
|
See [`packages/e2e/fixtures/tanstack-start`](https://github.com/james-elicx/rsbuild-plugin-cloudflare/tree/main/packages/e2e/fixtures/tanstack-start) for
|
|
159
170
|
a complete app.
|
|
160
171
|
|
|
172
|
+
[React Server Components](https://tanstack.com/start/latest/docs/framework/react/guide/server-components)
|
|
173
|
+
run in the Worker too, once they're enabled with `rsc: { enabled: true }` in
|
|
174
|
+
`tanstackStart()`'s options. TanStack Start resolves `react-server-dom-rspack`
|
|
175
|
+
from the app's root, so add it as a dependency. See
|
|
176
|
+
[`packages/e2e/fixtures/tanstack-start-rsc`](https://github.com/james-elicx/rsbuild-plugin-cloudflare/tree/main/packages/e2e/fixtures/tanstack-start-rsc).
|
|
177
|
+
|
|
161
178
|
## Differences from the Vite plugin
|
|
162
179
|
|
|
163
180
|
The plugin replaces Vite's module runner with Rsbuild's bundles, so behaviour
|