@react-router/serve 8.3.1 → 8.5.0
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/CHANGELOG.md +25 -0
- package/dist/cli.js +21 -8
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# `@react-router/serve`
|
|
2
2
|
|
|
3
|
+
## v8.5.0
|
|
4
|
+
|
|
5
|
+
### Unstable Changes
|
|
6
|
+
|
|
7
|
+
⚠️ _[Unstable features](https://reactrouter.com/community/api-development-strategy#unstable-flags) are not recommended for production use_
|
|
8
|
+
|
|
9
|
+
- Support API-only builds in `react-router-serve` by serving client documents and forwarding data and route discovery requests to the React Router runtime ([#15601](https://github.com/remix-run/react-router/pull/15601))
|
|
10
|
+
- Serve prerendered documents when available and use the generated SPA fallback for non-prerendered paths
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies:
|
|
15
|
+
- [`react-router@8.5.0`](https://github.com/remix-run/react-router/releases/tag/react-router@8.5.0)
|
|
16
|
+
- [`@react-router/express@8.5.0`](https://github.com/remix-run/react-router/releases/tag/@react-router/express@8.5.0)
|
|
17
|
+
- [`@react-router/node@8.5.0`](https://github.com/remix-run/react-router/releases/tag/@react-router/node@8.5.0)
|
|
18
|
+
|
|
19
|
+
## v8.4.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies:
|
|
24
|
+
- [`react-router@8.4.0`](https://github.com/remix-run/react-router/releases/tag/react-router@8.4.0)
|
|
25
|
+
- [`@react-router/express@8.4.0`](https://github.com/remix-run/react-router/releases/tag/@react-router/express@8.4.0)
|
|
26
|
+
- [`@react-router/node@8.4.0`](https://github.com/remix-run/react-router/releases/tag/@react-router/node@8.4.0)
|
|
27
|
+
|
|
3
28
|
## v8.3.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/serve v8.
|
|
3
|
+
* @react-router/serve v8.5.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -89,8 +89,8 @@ async function run() {
|
|
|
89
89
|
let buildPath = path.resolve(buildPathArg);
|
|
90
90
|
let buildModule = await import(url.pathToFileURL(buildPath).href);
|
|
91
91
|
let build;
|
|
92
|
-
let isRSCBuild =
|
|
93
|
-
if (isRSCBuild
|
|
92
|
+
let isRSCBuild = isRSCServerBuild(buildModule);
|
|
93
|
+
if (isRSCBuild) {
|
|
94
94
|
const config = {
|
|
95
95
|
publicPath: "/",
|
|
96
96
|
assetsBuildDirectory: path.join("..", "client"),
|
|
@@ -102,6 +102,7 @@ async function run() {
|
|
|
102
102
|
assetsBuildDirectory: path.resolve(path.dirname(buildPath), config.assetsBuildDirectory)
|
|
103
103
|
};
|
|
104
104
|
} else build = buildModule;
|
|
105
|
+
let assetsBuildDirectory = path.isAbsolute(build.assetsBuildDirectory) ? build.assetsBuildDirectory : path.resolve(process.cwd(), build.assetsBuildDirectory);
|
|
105
106
|
let onListen = (error) => {
|
|
106
107
|
if (error) throw error;
|
|
107
108
|
let address = process.env.HOST || Object.values(os.networkInterfaces()).flat().find((ip) => String(ip?.family).includes("4") && !ip?.internal)?.address;
|
|
@@ -112,17 +113,29 @@ async function run() {
|
|
|
112
113
|
app.disable("x-powered-by");
|
|
113
114
|
if (!isRSCBuild) app.use(compression());
|
|
114
115
|
let expressPublicPath = getExpressPath(build.publicPath);
|
|
115
|
-
app.use(path.posix.join(expressPublicPath, "assets"), express.static(path.join(
|
|
116
|
+
app.use(path.posix.join(expressPublicPath, "assets"), express.static(path.join(assetsBuildDirectory, "assets"), {
|
|
116
117
|
immutable: true,
|
|
117
118
|
maxAge: "1y"
|
|
118
119
|
}));
|
|
119
|
-
app.use(expressPublicPath, express.static(
|
|
120
|
+
app.use(expressPublicPath, express.static(assetsBuildDirectory));
|
|
120
121
|
app.use(express.static("public", { maxAge: "1h" }));
|
|
121
|
-
app.use("/.well-known", express.static(path.join(
|
|
122
|
+
app.use("/.well-known", express.static(path.join(assetsBuildDirectory, ".well-known")));
|
|
122
123
|
app.use(morgan("tiny"));
|
|
123
124
|
if (build.fetch) app.all("/{*splat}", createRequestListener(build.fetch));
|
|
124
|
-
else
|
|
125
|
-
build
|
|
125
|
+
else if (buildModule.unstable_apiOnly === true) {
|
|
126
|
+
let serverBuild = build;
|
|
127
|
+
let manifestPath = serverBuild.routeDiscovery.mode === "lazy" ? path.posix.join(serverBuild.basename ?? "/", serverBuild.routeDiscovery.manifestPath) : void 0;
|
|
128
|
+
let handler = createRequestHandler({
|
|
129
|
+
build: serverBuild,
|
|
130
|
+
mode: process.env.NODE_ENV
|
|
131
|
+
});
|
|
132
|
+
let fallbackFile = fs.existsSync(path.join(assetsBuildDirectory, "__spa-fallback.html")) ? "__spa-fallback.html" : "index.html";
|
|
133
|
+
app.all("/{*splat}", (req, res, next) => {
|
|
134
|
+
if (req.path.endsWith(".data") || req.path === manifestPath) handler(req, res, next);
|
|
135
|
+
else res.sendFile(fallbackFile, { root: assetsBuildDirectory });
|
|
136
|
+
});
|
|
137
|
+
} else app.all("/{*splat}", createRequestHandler({
|
|
138
|
+
build,
|
|
126
139
|
mode: process.env.NODE_ENV
|
|
127
140
|
}));
|
|
128
141
|
let server = process.env.HOST ? app.listen(port, process.env.HOST, onListen) : app.listen(port, onListen);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/serve",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.5.0",
|
|
5
5
|
"description": "Production application server for React Router",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/remix-run/react-router/issues"
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"express": "^5.2.1",
|
|
40
40
|
"morgan": "^1.10.1",
|
|
41
41
|
"source-map-support": "^0.5.21",
|
|
42
|
-
"@react-router/
|
|
43
|
-
"@react-router/
|
|
42
|
+
"@react-router/express": "8.5.0",
|
|
43
|
+
"@react-router/node": "8.5.0"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"react-router": "8.
|
|
46
|
+
"react-router": "8.5.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/compression": "^1.8.1",
|