@react-router/serve 7.9.1-pre.0 → 7.9.2-pre.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 +13 -4
- package/dist/cli.js +35 -9
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
# `@react-router/serve`
|
|
2
2
|
|
|
3
|
-
## 7.9.
|
|
3
|
+
## 7.9.2-pre.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
7
|
- Updated dependencies:
|
|
8
|
-
- `react-router@7.9.
|
|
9
|
-
- `@react-router/node@7.9.
|
|
10
|
-
- `@react-router/express@7.9.
|
|
8
|
+
- `react-router@7.9.2-pre.0`
|
|
9
|
+
- `@react-router/node@7.9.2-pre.0`
|
|
10
|
+
- `@react-router/express@7.9.2-pre.0`
|
|
11
|
+
|
|
12
|
+
## 7.9.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies:
|
|
17
|
+
- `react-router@7.9.1`
|
|
18
|
+
- `@react-router/node@7.9.1`
|
|
19
|
+
- `@react-router/express@7.9.1`
|
|
11
20
|
|
|
12
21
|
## 7.9.0
|
|
13
22
|
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/serve v7.9.
|
|
3
|
+
* @react-router/serve v7.9.2-pre.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -39,6 +39,7 @@ var import_node_os = __toESM(require("os"));
|
|
|
39
39
|
var import_node_path = __toESM(require("path"));
|
|
40
40
|
var import_node_url = __toESM(require("url"));
|
|
41
41
|
var import_express = require("@react-router/express");
|
|
42
|
+
var import_node_fetch_server = require("@mjackson/node-fetch-server");
|
|
42
43
|
var import_compression = __toESM(require("compression"));
|
|
43
44
|
var import_express2 = __toESM(require("express"));
|
|
44
45
|
var import_morgan = __toESM(require("morgan"));
|
|
@@ -62,6 +63,9 @@ import_source_map_support.default.install({
|
|
|
62
63
|
}
|
|
63
64
|
});
|
|
64
65
|
run();
|
|
66
|
+
function isRSCServerBuild(build) {
|
|
67
|
+
return "fetch" in build && typeof build.fetch === "function";
|
|
68
|
+
}
|
|
65
69
|
function parseNumber(raw) {
|
|
66
70
|
if (raw === void 0) return void 0;
|
|
67
71
|
let maybe = Number(raw);
|
|
@@ -77,7 +81,25 @@ async function run() {
|
|
|
77
81
|
process.exit(1);
|
|
78
82
|
}
|
|
79
83
|
let buildPath = import_node_path.default.resolve(buildPathArg);
|
|
80
|
-
let
|
|
84
|
+
let buildModule = await import(import_node_url.default.pathToFileURL(buildPath).href);
|
|
85
|
+
let build;
|
|
86
|
+
if (buildModule.default && typeof buildModule.default === "function") {
|
|
87
|
+
const config = {
|
|
88
|
+
publicPath: "/",
|
|
89
|
+
assetsBuildDirectory: "../client",
|
|
90
|
+
...buildModule.unstable_reactRouterServeConfig || {}
|
|
91
|
+
};
|
|
92
|
+
build = {
|
|
93
|
+
fetch: buildModule.default,
|
|
94
|
+
publicPath: config.publicPath,
|
|
95
|
+
assetsBuildDirectory: import_node_path.default.resolve(
|
|
96
|
+
import_node_path.default.dirname(buildPath),
|
|
97
|
+
config.assetsBuildDirectory
|
|
98
|
+
)
|
|
99
|
+
};
|
|
100
|
+
} else {
|
|
101
|
+
build = buildModule;
|
|
102
|
+
}
|
|
81
103
|
let onListen = () => {
|
|
82
104
|
let address = process.env.HOST || Object.values(import_node_os.default.networkInterfaces()).flat().find((ip) => String(ip?.family).includes("4") && !ip?.internal)?.address;
|
|
83
105
|
if (!address) {
|
|
@@ -101,13 +123,17 @@ async function run() {
|
|
|
101
123
|
app.use(build.publicPath, import_express2.default.static(build.assetsBuildDirectory));
|
|
102
124
|
app.use(import_express2.default.static("public", { maxAge: "1h" }));
|
|
103
125
|
app.use((0, import_morgan.default)("tiny"));
|
|
104
|
-
|
|
105
|
-
"*",
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
if (isRSCServerBuild(build)) {
|
|
127
|
+
app.all("*", (0, import_node_fetch_server.createRequestListener)(build.fetch));
|
|
128
|
+
} else {
|
|
129
|
+
app.all(
|
|
130
|
+
"*",
|
|
131
|
+
(0, import_express.createRequestHandler)({
|
|
132
|
+
build,
|
|
133
|
+
mode: process.env.NODE_ENV
|
|
134
|
+
})
|
|
135
|
+
);
|
|
136
|
+
}
|
|
111
137
|
let server = process.env.HOST ? app.listen(port, process.env.HOST, onListen) : app.listen(port, onListen);
|
|
112
138
|
["SIGTERM", "SIGINT"].forEach((signal) => {
|
|
113
139
|
process.once(signal, () => server?.close(console.error));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/serve",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.2-pre.0",
|
|
4
4
|
"description": "Production application server for React Router",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/remix-run/react-router/issues"
|
|
@@ -32,16 +32,17 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@mjackson/node-fetch-server": "^0.2.0",
|
|
35
36
|
"compression": "^1.7.4",
|
|
36
37
|
"express": "^4.19.2",
|
|
37
38
|
"get-port": "5.1.1",
|
|
38
39
|
"morgan": "^1.10.0",
|
|
39
40
|
"source-map-support": "^0.5.21",
|
|
40
|
-
"@react-router/express": "7.9.
|
|
41
|
-
"@react-router/node": "7.9.
|
|
41
|
+
"@react-router/express": "7.9.2-pre.0",
|
|
42
|
+
"@react-router/node": "7.9.2-pre.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"react-router": "7.9.
|
|
45
|
+
"react-router": "7.9.2-pre.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@types/compression": "^1.7.0",
|