Skip to content

Commit 37ee74e

Browse files
committed
Merge branch 'release-next' into dev
2 parents f2b4d53 + 03c5cb5 commit 37ee74e

File tree

17 files changed

+770
-37
lines changed

17 files changed

+770
-37
lines changed

integration/client-data-test.ts

Lines changed: 416 additions & 3 deletions
Large diffs are not rendered by default.

packages/remix-dev/CHANGELOG.md

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,158 @@
11
# `@remix-run/dev`
22

3+
## 2.4.0
4+
5+
### Minor Changes
6+
7+
- Vite: exclude modules within `.server` directories from client build ([#8154](https://github.com/remix-run/remix/pull/8154))
8+
9+
- Add support for `clientLoader`/`clientAction`/`HydrateFallback` route exports ([RFC](https://github.com/remix-run/remix/discussions/7634)) ([#8173](https://github.com/remix-run/remix/pull/8173))
10+
11+
Remix now supports loaders/actions that run on the client (in addition to, or instead of the loader/action that runs on the server). While we still recommend server loaders/actions for the majority of your data needs in a Remix app - these provide some levers you can pull for more advanced use-cases such as:
12+
13+
- Leveraging a data source local to the browser (i.e., `localStorage`)
14+
- Managing a client-side cache of server data (like `IndexedDB`)
15+
- Bypassing the Remix server in a BFF setup and hitting your API directly from the browser
16+
- Migrating a React Router SPA to a Remix application
17+
18+
By default, `clientLoader` will not run on hydration, and will only run on subsequent client side navigations.
19+
20+
If you wish to run your client loader on hydration, you can set `clientLoader.hydrate=true` to force Remix to execute it on initial page load. Keep in mind that Remix will still SSR your route component so you should ensure that there is no new _required_ data being added by your `clientLoader`.
21+
22+
If your `clientLoader` needs to run on hydration and adds data you require to render the route component, you can export a `HydrateFallback` component that will render during SSR, and then your route component will not render until the `clientLoader` has executed on hydration.
23+
24+
`clientAction` is simpler than `clientLoader` because it has no hydration use-cases. `clientAction` will only run on client-side navigations.
25+
26+
For more information, please refer to the [`clientLoader`](https://remix.run/route/client-loader) and [`clientAction`](https://remix.run/route/client-action) documentation.
27+
28+
- Vite: Strict route exports ([#8171](https://github.com/remix-run/remix/pull/8171))
29+
30+
With Vite, Remix gets stricter about which exports are allowed from your route modules.
31+
Previously, the Remix compiler would allow any export from routes.
32+
While this was convenient, it was also a common source of bugs that were hard to track down because they only surfaced at runtime.
33+
34+
For more, see <https://remix.run/docs/en/main/future/vite#strict-route-exports>
35+
36+
- Add a new `future.v3_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. For more information, please see the React Router [`6.21.0` Release Notes](https://github.com/remix-run/react-router/blob/release-next/CHANGELOG.md#futurev7_relativesplatpath) and the [`useResolvedPath` docs](https://remix.run/hooks/use-resolved-path#splat-paths). ([#8216](https://github.com/remix-run/remix/pull/8216))
37+
38+
### Patch Changes
39+
40+
- Upgrade Vite peer dependency range to v5 ([#8172](https://github.com/remix-run/remix/pull/8172))
41+
42+
- Support HMR for routes with `handle` export in Vite dev ([#8022](https://github.com/remix-run/remix/pull/8022))
43+
44+
- Fix flash of unstyled content for non-Express custom servers in Vite dev ([#8076](https://github.com/remix-run/remix/pull/8076))
45+
46+
- Bundle CSS imported in client entry file in Vite plugin ([#8143](https://github.com/remix-run/remix/pull/8143))
47+
48+
- Change Vite build output paths to fix a conflict between how Vite and the Remix compiler each manage the `public` directory. ([#8077](https://github.com/remix-run/remix/pull/8077))
49+
50+
**This is a breaking change for projects using the unstable Vite plugin.**
51+
52+
The server is now compiled into `build/server` rather than `build`, and the client is now compiled into `build/client` rather than `public`.
53+
54+
For more information on the changes and guidance on how to migrate your project, refer to the updated [Remix Vite documentation](https://remix.run/docs/en/main/future/vite).
55+
56+
- Remove undocumented `legacyCssImports` option from Vite plugin due to issues with `?url` imports of CSS files not being processed correctly in Vite ([#8096](https://github.com/remix-run/remix/pull/8096))
57+
58+
- Vite: fix access to default `entry.{client,server}.tsx` within pnpm workspace on Windows ([#8057](https://github.com/remix-run/remix/pull/8057))
59+
60+
- Remove `unstable_createViteServer` and `unstable_loadViteServerBuild` which were only minimal wrappers around Vite's `createServer` and `ssrLoadModule` functions when using a custom server. ([#8120](https://github.com/remix-run/remix/pull/8120))
61+
62+
**This is a breaking change for projects using the unstable Vite plugin with a custom server.**
63+
64+
Instead, we now provide `unstable_viteServerBuildModuleId` so that custom servers interact with Vite directly rather than via Remix APIs, for example:
65+
66+
```diff
67+
-import {
68+
- unstable_createViteServer,
69+
- unstable_loadViteServerBuild,
70+
-} from "@remix-run/dev";
71+
+import { unstable_viteServerBuildModuleId } from "@remix-run/dev";
72+
```
73+
74+
Creating the Vite server in middleware mode:
75+
76+
```diff
77+
const vite =
78+
process.env.NODE_ENV === "production"
79+
? undefined
80+
- : await unstable_createViteServer();
81+
+ : await import("vite").then(({ createServer }) =>
82+
+ createServer({
83+
+ server: {
84+
+ middlewareMode: true,
85+
+ },
86+
+ })
87+
+ );
88+
```
89+
90+
Loading the Vite server build in the request handler:
91+
92+
```diff
93+
app.all(
94+
"*",
95+
createRequestHandler({
96+
build: vite
97+
- ? () => unstable_loadViteServerBuild(vite)
98+
+ ? () => vite.ssrLoadModule(unstable_viteServerBuildModuleId)
99+
: await import("./build/server/index.js"),
100+
})
101+
);
102+
```
103+
104+
- Pass request handler errors to `vite.ssrFixStacktrace` in Vite dev to ensure stack traces correctly map to the original source code ([#8066](https://github.com/remix-run/remix/pull/8066))
105+
106+
- Vite: Preserve names for exports from .client imports ([#8200](https://github.com/remix-run/remix/pull/8200))
107+
108+
Unlike `.server` modules, the main idea is not to prevent code from leaking into the server build
109+
since the client build is already public. Rather, the goal is to isolate the SSR render from client-only code.
110+
Routes need to import code from `.client` modules without compilation failing and then rely on runtime checks
111+
to determine if the code is running on the server or client.
112+
113+
Replacing `.client` modules with empty modules would cause the build to fail as ESM named imports are statically analyzed.
114+
So instead, we preserve the named export but replace each exported value with an empty object.
115+
That way, the import is valid at build time and the standard runtime checks can be used to determine if then
116+
code is running on the server or client.
117+
118+
- Add `@remix-run/node` to Vite's `optimizeDeps.include` array ([#8177](https://github.com/remix-run/remix/pull/8177))
119+
120+
- Improve Vite plugin performance ([#8121](https://github.com/remix-run/remix/pull/8121))
121+
122+
- Parallelize detection of route module exports
123+
- Disable `server.preTransformRequests` in Vite child compiler since it's only used to process route modules
124+
125+
- Remove automatic global Node polyfill installation from the built-in Vite dev server and instead allow explicit opt-in. ([#8119](https://github.com/remix-run/remix/pull/8119))
126+
127+
**This is a breaking change for projects using the unstable Vite plugin without a custom server.**
128+
129+
If you're not using a custom server, you should call `installGlobals` in your Vite config instead.
130+
131+
```diff
132+
import { unstable_vitePlugin as remix } from "@remix-run/dev";
133+
+import { installGlobals } from "@remix-run/node";
134+
import { defineConfig } from "vite";
135+
136+
+installGlobals();
137+
138+
export default defineConfig({
139+
plugins: [remix()],
140+
});
141+
```
142+
143+
- Vite: Errors at build-time when client imports .server default export ([#8184](https://github.com/remix-run/remix/pull/8184))
144+
145+
Remix already stripped .server file code before ensuring that server code never makes it into the client.
146+
That results in errors when client code tries to import server code, which is exactly what we want!
147+
But those errors were happening at runtime for default imports.
148+
A better experience is to have those errors happen at build-time so that you guarantee that your users won't hit them.
149+
150+
- Fix `request instanceof Request` checks when using Vite dev server ([#8062](https://github.com/remix-run/remix/pull/8062))
151+
152+
- Updated dependencies:
153+
- `@remix-run/[email protected]`
154+
- `@remix-run/[email protected]`
155+
3156
## 2.3.1
4157

5158
### Patch Changes

packages/remix-dev/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/dev",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "Dev tools and CLI for Remix",
55
"homepage": "https://remix.run",
66
"bugs": {
@@ -28,9 +28,9 @@
2828
"@babel/types": "^7.22.5",
2929
"@mdx-js/mdx": "^2.3.0",
3030
"@npmcli/package-json": "^4.0.1",
31-
"@remix-run/node": "2.3.1",
32-
"@remix-run/router": "1.14.0-pre.0",
33-
"@remix-run/server-runtime": "2.3.1",
31+
"@remix-run/node": "2.4.0",
32+
"@remix-run/router": "1.14.0",
33+
"@remix-run/server-runtime": "2.4.0",
3434
"@types/mdx": "^2.0.5",
3535
"@vanilla-extract/integration": "^6.2.0",
3636
"arg": "^5.0.1",
@@ -73,7 +73,7 @@
7373
"ws": "^7.4.5"
7474
},
7575
"devDependencies": {
76-
"@remix-run/serve": "2.3.1",
76+
"@remix-run/serve": "2.4.0",
7777
"@types/cacache": "^17.0.0",
7878
"@types/cross-spawn": "^6.0.2",
7979
"@types/gunzip-maybe": "^1.4.0",
@@ -94,7 +94,7 @@
9494
"vite": "^5.0.0"
9595
},
9696
"peerDependencies": {
97-
"@remix-run/serve": "^2.3.1",
97+
"@remix-run/serve": "^2.4.0",
9898
"typescript": "^5.1.0",
9999
"vite": "^5.0.0"
100100
},

packages/remix-express/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# `@remix-run/express`
22

3+
## 2.4.0
4+
5+
### Patch Changes
6+
7+
- Updated dependencies:
8+
- `@remix-run/[email protected]`
9+
310
## 2.3.1
411

512
### Patch Changes

packages/remix-express/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/express",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "Express server request handler for Remix",
55
"bugs": {
66
"url": "https://github.com/remix-run/remix/issues"
@@ -14,7 +14,7 @@
1414
"main": "dist/index.js",
1515
"typings": "dist/index.d.ts",
1616
"dependencies": {
17-
"@remix-run/node": "2.3.1"
17+
"@remix-run/node": "2.4.0"
1818
},
1919
"devDependencies": {
2020
"@types/express": "^4.17.9",

packages/remix-node/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# `@remix-run/node`
22

3+
## 2.4.0
4+
5+
### Minor Changes
6+
7+
- Deprecate `DataFunctionArgs` in favor of `LoaderFunctionArgs`/`ActionFunctionArgs`. This is aimed at keeping the types aligned across server/client loaders/actions now that `clientLoader`/`clientActon` functions have `serverLoader`/`serverAction` parameters which differentiate `ClientLoaderFunctionArgs`/`ClientActionFunctionArgs`. ([#8173](https://github.com/remix-run/remix/pull/8173))
8+
9+
### Patch Changes
10+
11+
- Update to `@remix-run/[email protected]` ([#8231](https://github.com/remix-run/remix/pull/8231))
12+
- Updated dependencies:
13+
- `@remix-run/[email protected]`
14+
315
## 2.3.1
416

517
### Patch Changes

packages/remix-node/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/node",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "Node.js platform abstractions for Remix",
55
"bugs": {
66
"url": "https://github.com/remix-run/remix/issues"
@@ -17,8 +17,8 @@
1717
"./install.js"
1818
],
1919
"dependencies": {
20-
"@remix-run/server-runtime": "2.3.1",
21-
"@remix-run/web-fetch": "^4.4.1",
20+
"@remix-run/server-runtime": "2.4.0",
21+
"@remix-run/web-fetch": "^4.4.2",
2222
"@remix-run/web-file": "^3.1.0",
2323
"@remix-run/web-stream": "^1.1.0",
2424
"@web3-storage/multipart-parser": "^1.0.0",

packages/remix-serve/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# `@remix-run/serve`
22

3+
## 2.4.0
4+
5+
### Patch Changes
6+
7+
- Fix source map loading when file has `?t=timestamp` suffix (rebuilds) ([#8174](https://github.com/remix-run/remix/pull/8174))
8+
- Updated dependencies:
9+
- `@remix-run/[email protected]`
10+
- `@remix-run/[email protected]`
11+
312
## 2.3.1
413

514
### Patch Changes

packages/remix-serve/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/serve",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "Production application server for Remix",
55
"bugs": {
66
"url": "https://github.com/remix-run/remix/issues"
@@ -15,8 +15,8 @@
1515
"remix-serve": "dist/cli.js"
1616
},
1717
"dependencies": {
18-
"@remix-run/express": "2.3.1",
19-
"@remix-run/node": "2.3.1",
18+
"@remix-run/express": "2.4.0",
19+
"@remix-run/node": "2.4.0",
2020
"chokidar": "^3.5.3",
2121
"compression": "^1.7.4",
2222
"express": "^4.17.1",

packages/remix-server-runtime/CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,37 @@
11
# `@remix-run/server-runtime`
22

3+
## 2.4.0
4+
5+
### Minor Changes
6+
7+
- Add support for `clientLoader`/`clientAction`/`HydrateFallback` route exports ([RFC](https://github.com/remix-run/remix/discussions/7634)). ([#8173](https://github.com/remix-run/remix/pull/8173))
8+
9+
Remix now supports loaders/actions that run on the client (in addition to, or instead of the loader/action that runs on the server). While we still recommend server loaders/actions for the majority of your data needs in a Remix app - these provide some levers you can pull for more advanced use-cases such as:
10+
11+
- Leveraging a data source local to the browser (i.e., `localStorage`)
12+
- Managing a client-side cache of server data (like `IndexedDB`)
13+
- Bypassing the Remix server in a BFF setup and hitting your API directly from the browser
14+
- Migrating a React Router SPA to a Remix application
15+
16+
By default, `clientLoader` will not run on hydration, and will only run on subsequent client side navigations.
17+
18+
If you wish to run your client loader on hydration, you can set `clientLoader.hydrate=true` to force Remix to execute it on initial page load. Keep in mind that Remix will still SSR your route component so you should ensure that there is no new _required_ data being added by your `clientLoader`.
19+
20+
If your `clientLoader` needs to run on hydration and adds data you require to render the route component, you can export a `HydrateFallback` component that will render during SSR, and then your route component will not render until the `clientLoader` has executed on hydration.
21+
22+
`clientAction` is simpler than `clientLoader` because it has no hydration use-cases. `clientAction` will only run on client-side navigations.
23+
24+
For more information, please refer to the [`clientLoader`](https://remix.run/route/client-loader) and [`clientAction`](https://remix.run/route/client-action) documentation.
25+
26+
- Deprecate `DataFunctionArgs` in favor of `LoaderFunctionArgs`/`ActionFunctionArgs`. This is aimed at keeping the types aligned across server/client loaders/actions now that `clientLoader`/`clientActon` functions have `serverLoader`/`serverAction` parameters which differentiate `ClientLoaderFunctionArgs`/`ClientActionFunctionArgs`. ([#8173](https://github.com/remix-run/remix/pull/8173))
27+
28+
- Add a new `future.v3_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. For more information, please see the React Router [`6.21.0` Release Notes](https://github.com/remix-run/react-router/blob/release-next/CHANGELOG.md#futurev7_relativesplatpath) and the [`useResolvedPath` docs](https://remix.run/hooks/use-resolved-path#splat-paths). ([#8216](https://github.com/remix-run/remix/pull/8216))
29+
30+
### Patch Changes
31+
32+
- Fix flash of unstyled content for non-Express custom servers in Vite dev ([#8076](https://github.com/remix-run/remix/pull/8076))
33+
- Pass request handler errors to `vite.ssrFixStacktrace` in Vite dev to ensure stack traces correctly map to the original source code ([#8066](https://github.com/remix-run/remix/pull/8066))
34+
335
## 2.3.1
436

537
No significant changes to this package were made in this release. [See the repo `CHANGELOG.md`](https://github.com/remix-run/remix/blob/main/CHANGELOG.md) for an overview of all changes in v2.3.1.

packages/remix-server-runtime/jsonify.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ export type Jsonify<T> =
2121
T extends Number ? number :
2222
T extends Boolean ? boolean :
2323

24+
// Promises JSON.stringify to an empty object
25+
T extends Promise<unknown> ? EmptyObject :
26+
2427
// Map & Set
2528
T extends Map<unknown, unknown> ? EmptyObject :
2629
T extends Set<unknown> ? EmptyObject :
@@ -119,6 +122,7 @@ type _tests = [
119122
Expect<Equal<Jsonify<String>, string>>,
120123
Expect<Equal<Jsonify<Number>, number>>,
121124
Expect<Equal<Jsonify<Boolean>, boolean>>,
125+
Expect<Equal<Jsonify<Promise<string>>, EmptyObject>>,
122126

123127
// Map & Set
124128
Expect<Equal<Jsonify<Map<unknown, unknown>>, EmptyObject>>,
@@ -251,7 +255,7 @@ type NeverToNull<T> = [T] extends [never] ? null : T;
251255

252256
// adapted from https://github.com/sindresorhus/type-fest/blob/main/source/empty-object.d.ts
253257
declare const emptyObjectSymbol: unique symbol;
254-
type EmptyObject = { [emptyObjectSymbol]?: never };
258+
export type EmptyObject = { [emptyObjectSymbol]?: never };
255259

256260
// adapted from https://github.com/type-challenges/type-challenges/blob/main/utils/index.d.ts
257261
type IsAny<T> = 0 extends 1 & T ? true : false;

packages/remix-server-runtime/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@remix-run/server-runtime",
3-
"version": "2.3.1",
3+
"version": "2.4.0",
44
"description": "Server runtime for Remix",
55
"bugs": {
66
"url": "https://github.com/remix-run/remix/issues"
@@ -16,7 +16,7 @@
1616
"typings": "dist/index.d.ts",
1717
"module": "dist/esm/index.js",
1818
"dependencies": {
19-
"@remix-run/router": "1.14.0-pre.0",
19+
"@remix-run/router": "1.14.0",
2020
"@types/cookie": "^0.5.3",
2121
"@web3-storage/multipart-parser": "^1.0.0",
2222
"cookie": "^0.5.0",

packages/remix-server-runtime/routeModules.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type ClientActionFunction = (
5454
* Arguments passed to a route `clientAction` function
5555
* @private Public API is exported from @remix-run/react
5656
*/
57-
type ClientActionFunctionArgs = RRActionFunctionArgs<undefined> & {
57+
export type ClientActionFunctionArgs = RRActionFunctionArgs<undefined> & {
5858
serverAction: <T = AppData>() => Promise<SerializeFrom<T>>;
5959
};
6060

@@ -87,7 +87,7 @@ type ClientLoaderFunction = ((
8787
* Arguments passed to a route `clientLoader` function
8888
* @private Public API is exported from @remix-run/react
8989
*/
90-
type ClientLoaderFunctionArgs = RRLoaderFunctionArgs<undefined> & {
90+
export type ClientLoaderFunctionArgs = RRLoaderFunctionArgs<undefined> & {
9191
serverLoader: <T = AppData>() => Promise<SerializeFrom<T>>;
9292
};
9393

0 commit comments

Comments
 (0)