You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
1
# master
2
2
3
+
- Fix dev reload experience of the Vite dev setup.
3
4
- Expose `RequestController` and `Handlers` as record-of-functions APIs so user code can migrate from `requestController->RequestController.setStatus(404)` to `requestController.setStatus(404)` and from `handler->ResX.Handlers.handleRequest({...})` to `handler.handleRequest({...})`; the old free-function surface is still available but deprecated.
4
5
- BREAKING: Remove `ResX.BunUtils.serveStaticFile`; static assets now go through generated `ResXAssets.staticAssetRoutes`.
5
6
- Add `__rawProps?: Dict.t<JSON.t>` on JSX DOM props as a low-level escape hatch for arbitrary attributes (escaped values, invalid/non-serializable entries ignored, may emit duplicates after typed props), with accompanying tests and README docs.
@@ -123,11 +123,11 @@ There! If you want, you can also set up a bunch of scripts in `package.json` tha
123
123
{
124
124
"scripts": {
125
125
"start": "NODE_ENV=production bun run src/App.js",
126
-
"build": "NODE_ENV=production && bun run build:vite && bun run build:res",
126
+
"build": "NODE_ENV=production bun run build:vite && bun run build:res",
127
127
"build:vite": "vite build",
128
128
"build:res": "rescript",
129
129
"clean:res": "rescript clean",
130
-
"dev:res": "rescript build -w",
130
+
"dev:res": "rescript watch",
131
131
"dev:server": "bun --watch run src/App.js",
132
132
"dev:vite": "vite",
133
133
"dev": "concurrently 'bun:dev:*'"
@@ -207,15 +207,17 @@ let portString = server->Bun.Server.port->Int.toString
207
207
208
208
Console.log(`Listening! on localhost:${portString}`)
209
209
210
-
// Run the dev server, responsible for hot module reloading etc, when in dev mode.
210
+
// Run the small dev socket server used to trigger page refreshes after backend restarts.
211
211
if ResX.BunUtils.isDev {
212
212
ResX.BunUtils.runDevServer(~port)
213
213
}
214
214
```
215
215
216
216
Note that there's plenty of more things you can configure here, but for the sake of keeping it simple we'll just go with the basics.
217
217
218
-
You can now start up the dev environment: `bun run dev`. Open up `localhost:9000` and you should see your "Start page!" string.
218
+
You can now start up the dev environment: `bun run dev`. Open the Vite URL, for example `http://localhost:9000`, and you should see your "Start page!" string.
219
+
220
+
In dev, browse the app through the Vite server, not the raw Bun app server port. ResX serves dev assets with root-relative URLs from the Vite origin and performs a full page refresh after the backend restarts and reconnects.
219
221
220
222
There's a ton more to ResX of course, but this should get you started.
221
223
@@ -373,7 +375,7 @@ Then, include it in your ReScript:
373
375
</head>
374
376
```
375
377
376
-
There! It's now available to you, and Vite will both transform and hot module reload the asset if it's possible.
378
+
There! It's now available to you, and Vite will transform it for both dev and production builds. In dev, assets are served from the Vite origin using root-relative URLs.
377
379
378
380
#### Thinking about client side JavaScript
379
381
@@ -1218,7 +1220,8 @@ render: async ({path}) => {
1218
1220
ResX comes with its own Vite plugin that takes care of all configuration for you. It will:
1219
1221
1220
1222
- Ensure all ResX assets are handled and included properly
1221
-
- Ensure that Hot Module Reloading works for all assets and that Vite dev mode is properly wired up to your local ResX dev server
1223
+
- Proxy your app server behind the Vite dev origin
1224
+
- Expose a same-origin dev socket so backend restarts trigger a hard page refresh once the app is ready again
1222
1225
1223
1226
> Note: Right now, using ResX with more elaborate Vite config than what's preconfigured for you might be problematic. This will change in the future though so that ResX is just another part of your Vite config. Open issues please when you find use cases you'd like supported but that doesn't work now.
Copy file name to clipboardExpand all lines: demo/README.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,8 @@ cd demo
19
19
bun run dev
20
20
```
21
21
22
+
Open the Vite URL that it prints, typically `http://localhost:9000`. In dev, the browser should use the Vite server origin rather than the raw Bun app port.
0 commit comments