@react-router/serve 7.0.0-pre.2 → 7.0.0-pre.4
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 +18 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +70 -57
- package/package.json +23 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# `@remix-run/serve`
|
|
2
2
|
|
|
3
|
+
## 7.0.0-pre.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- `react-router@7.0.0-pre.4`
|
|
9
|
+
- `@react-router/node@7.0.0-pre.4`
|
|
10
|
+
- `@react-router/express@7.0.0-pre.4`
|
|
11
|
+
|
|
12
|
+
## 7.0.0-pre.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies:
|
|
17
|
+
- `react-router@7.0.0-pre.3`
|
|
18
|
+
- `@react-router/express@7.0.0-pre.3`
|
|
19
|
+
- `@react-router/node@7.0.0-pre.3`
|
|
20
|
+
|
|
3
21
|
## 7.0.0-pre.2
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cli.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/serve v7.0.0-pre.
|
|
2
|
+
* @react-router/serve v7.0.0-pre.4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -8,42 +8,52 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var getPort__default = /*#__PURE__*/_interopDefaultLegacy(getPort);
|
|
11
|
+
"use strict";
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
35
34
|
|
|
35
|
+
// cli.ts
|
|
36
|
+
var import_node_fs = __toESM(require("fs"));
|
|
37
|
+
var import_node_os = __toESM(require("os"));
|
|
38
|
+
var import_node_path = __toESM(require("path"));
|
|
39
|
+
var import_node_url = __toESM(require("url"));
|
|
40
|
+
var import_express = require("@react-router/express");
|
|
41
|
+
var import_compression = __toESM(require("compression"));
|
|
42
|
+
var import_express2 = __toESM(require("express"));
|
|
43
|
+
var import_morgan = __toESM(require("morgan"));
|
|
44
|
+
var import_source_map_support = __toESM(require("source-map-support"));
|
|
45
|
+
var import_get_port = __toESM(require("get-port"));
|
|
36
46
|
process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
|
|
37
|
-
|
|
38
|
-
retrieveSourceMap: function
|
|
47
|
+
import_source_map_support.default.install({
|
|
48
|
+
retrieveSourceMap: function(source) {
|
|
39
49
|
let match = source.startsWith("file://");
|
|
40
50
|
if (match) {
|
|
41
|
-
let filePath =
|
|
51
|
+
let filePath = import_node_url.default.fileURLToPath(source);
|
|
42
52
|
let sourceMapPath = `${filePath}.map`;
|
|
43
|
-
if (
|
|
53
|
+
if (import_node_fs.default.existsSync(sourceMapPath)) {
|
|
44
54
|
return {
|
|
45
55
|
url: source,
|
|
46
|
-
map:
|
|
56
|
+
map: import_node_fs.default.readFileSync(sourceMapPath, "utf8")
|
|
47
57
|
};
|
|
48
58
|
}
|
|
49
59
|
}
|
|
@@ -52,50 +62,53 @@ sourceMapSupport__default["default"].install({
|
|
|
52
62
|
});
|
|
53
63
|
run();
|
|
54
64
|
function parseNumber(raw) {
|
|
55
|
-
if (raw ===
|
|
65
|
+
if (raw === void 0) return void 0;
|
|
56
66
|
let maybe = Number(raw);
|
|
57
|
-
if (Number.isNaN(maybe)) return
|
|
67
|
+
if (Number.isNaN(maybe)) return void 0;
|
|
58
68
|
return maybe;
|
|
59
69
|
}
|
|
60
70
|
async function run() {
|
|
61
|
-
let port = parseNumber(process.env.PORT) ??
|
|
62
|
-
port: 3000
|
|
63
|
-
}));
|
|
71
|
+
let port = parseNumber(process.env.PORT) ?? await (0, import_get_port.default)({ port: 3e3 });
|
|
64
72
|
let buildPathArg = process.argv[2];
|
|
65
73
|
if (!buildPathArg) {
|
|
66
74
|
console.error(`
|
|
67
75
|
Usage: react-router-serve <server-build-path> - e.g. react-router-serve build/server/index.js`);
|
|
68
76
|
process.exit(1);
|
|
69
77
|
}
|
|
70
|
-
let buildPath =
|
|
71
|
-
let build = await import(
|
|
78
|
+
let buildPath = import_node_path.default.resolve(buildPathArg);
|
|
79
|
+
let build = await import(import_node_url.default.pathToFileURL(buildPath).href);
|
|
72
80
|
let onListen = () => {
|
|
73
|
-
|
|
74
|
-
let address = process.env.HOST || ((_Object$values$flat$f = Object.values(os__default["default"].networkInterfaces()).flat().find(ip => String(ip === null || ip === void 0 ? void 0 : ip.family).includes("4") && !(ip !== null && ip !== void 0 && ip.internal))) === null || _Object$values$flat$f === void 0 ? void 0 : _Object$values$flat$f.address);
|
|
81
|
+
let address = process.env.HOST || Object.values(import_node_os.default.networkInterfaces()).flat().find((ip) => String(ip?.family).includes("4") && !ip?.internal)?.address;
|
|
75
82
|
if (!address) {
|
|
76
83
|
console.log(`[react-router-serve] http://localhost:${port}`);
|
|
77
84
|
} else {
|
|
78
|
-
console.log(
|
|
85
|
+
console.log(
|
|
86
|
+
`[react-router-serve] http://localhost:${port} (http://${address}:${port})`
|
|
87
|
+
);
|
|
79
88
|
}
|
|
80
89
|
};
|
|
81
|
-
let app =
|
|
90
|
+
let app = (0, import_express2.default)();
|
|
82
91
|
app.disable("x-powered-by");
|
|
83
|
-
app.use(
|
|
84
|
-
app.use(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
app.use(
|
|
93
|
-
app.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
app.use((0, import_compression.default)());
|
|
93
|
+
app.use(
|
|
94
|
+
import_node_path.default.posix.join(build.publicPath, "assets"),
|
|
95
|
+
import_express2.default.static(import_node_path.default.join(build.assetsBuildDirectory, "assets"), {
|
|
96
|
+
immutable: true,
|
|
97
|
+
maxAge: "1y"
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
app.use(build.publicPath, import_express2.default.static(build.assetsBuildDirectory));
|
|
101
|
+
app.use(import_express2.default.static("public", { maxAge: "1h" }));
|
|
102
|
+
app.use((0, import_morgan.default)("tiny"));
|
|
103
|
+
app.all(
|
|
104
|
+
"*",
|
|
105
|
+
(0, import_express.createRequestHandler)({
|
|
106
|
+
build,
|
|
107
|
+
mode: process.env.NODE_ENV
|
|
108
|
+
})
|
|
109
|
+
);
|
|
97
110
|
let server = process.env.HOST ? app.listen(port, process.env.HOST, onListen) : app.listen(port, onListen);
|
|
98
|
-
["SIGTERM", "SIGINT"].forEach(signal => {
|
|
99
|
-
process.once(signal, () => server
|
|
111
|
+
["SIGTERM", "SIGINT"].forEach((signal) => {
|
|
112
|
+
process.once(signal, () => server?.close(console.error));
|
|
100
113
|
});
|
|
101
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/serve",
|
|
3
|
-
"version": "7.0.0-pre.
|
|
3
|
+
"version": "7.0.0-pre.4",
|
|
4
4
|
"description": "Production application server for React Router",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/remix-run/react-router/issues"
|
|
@@ -17,23 +17,40 @@
|
|
|
17
17
|
"bin": {
|
|
18
18
|
"react-router-serve": "bin.js"
|
|
19
19
|
},
|
|
20
|
+
"wireit": {
|
|
21
|
+
"build": {
|
|
22
|
+
"command": "tsup",
|
|
23
|
+
"files": [
|
|
24
|
+
"*.ts",
|
|
25
|
+
"bin.js",
|
|
26
|
+
"tsconfig.json",
|
|
27
|
+
"package.json"
|
|
28
|
+
],
|
|
29
|
+
"output": [
|
|
30
|
+
"dist/**"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
20
34
|
"dependencies": {
|
|
21
35
|
"compression": "^1.7.4",
|
|
22
36
|
"express": "^4.19.2",
|
|
23
37
|
"get-port": "5.1.1",
|
|
24
38
|
"morgan": "^1.10.0",
|
|
25
39
|
"source-map-support": "^0.5.21",
|
|
26
|
-
"@react-router/express": "7.0.0-pre.
|
|
27
|
-
"@react-router/node": "7.0.0-pre.
|
|
40
|
+
"@react-router/express": "7.0.0-pre.4",
|
|
41
|
+
"@react-router/node": "7.0.0-pre.4"
|
|
28
42
|
},
|
|
29
43
|
"peerDependencies": {
|
|
30
|
-
"react-router": "7.0.0-pre.
|
|
44
|
+
"react-router": "7.0.0-pre.4"
|
|
31
45
|
},
|
|
32
46
|
"devDependencies": {
|
|
33
47
|
"@types/compression": "^1.7.0",
|
|
34
48
|
"@types/express": "^4.17.9",
|
|
35
49
|
"@types/morgan": "^1.9.2",
|
|
36
|
-
"@types/source-map-support": "^0.5.6"
|
|
50
|
+
"@types/source-map-support": "^0.5.6",
|
|
51
|
+
"tsup": "^8.3.0",
|
|
52
|
+
"typescript": "^5.1.6",
|
|
53
|
+
"wireit": "0.14.9"
|
|
37
54
|
},
|
|
38
55
|
"engines": {
|
|
39
56
|
"node": ">=20.0.0"
|
|
@@ -46,6 +63,6 @@
|
|
|
46
63
|
"README.md"
|
|
47
64
|
],
|
|
48
65
|
"scripts": {
|
|
49
|
-
"
|
|
66
|
+
"build": "wireit"
|
|
50
67
|
}
|
|
51
68
|
}
|