@react-router/dev 0.0.0-experimental-a334647a8 → 0.0.0-experimental-8d0ea8f67
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/bin.js +2 -4
- package/dist/cli/index.js +1396 -83
- package/dist/config/module-sync-enabled/false.cjs +1 -0
- package/dist/config/module-sync-enabled/index.mjs +4 -0
- package/dist/config/module-sync-enabled/true.mjs +2 -0
- package/dist/config.js +19 -1
- package/dist/routes.js +179 -12
- package/dist/vite/cloudflare.js +155 -17
- package/dist/vite.js +2739 -10
- package/package.json +8 -9
- package/dist/build-X3WBF6BT.js +0 -239
- package/dist/chunk-6V6JXLEB.js +0 -49
- package/dist/chunk-EOMY5OBU.js +0 -2626
- package/dist/chunk-MGU5SRRY.js +0 -81
- package/dist/chunk-OKN5PVYS.js +0 -31
- package/dist/chunk-P4FGVWCO.js +0 -219
- package/dist/chunk-RLHCL3MN.js +0 -57
- package/dist/dev-SGGX67CX.js +0 -74
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-8d0ea8f67",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"homepage": "https://reactrouter.com",
|
|
7
6
|
"bugs": {
|
|
8
7
|
"url": "https://github.com/remix-run/react-router/issues"
|
|
@@ -34,8 +33,8 @@
|
|
|
34
33
|
},
|
|
35
34
|
"imports": {
|
|
36
35
|
"#module-sync-enabled": {
|
|
37
|
-
"module-sync": "./config/module-sync-enabled/true.
|
|
38
|
-
"default": "./config/module-sync-enabled/false.cjs"
|
|
36
|
+
"module-sync": "./dist/config/module-sync-enabled/true.mjs",
|
|
37
|
+
"default": "./dist/config/module-sync-enabled/false.cjs"
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
"bin": {
|
|
@@ -88,7 +87,7 @@
|
|
|
88
87
|
"set-cookie-parser": "^2.6.0",
|
|
89
88
|
"valibot": "^0.41.0",
|
|
90
89
|
"vite-node": "3.0.0-beta.2",
|
|
91
|
-
"@react-router/node": "0.0.0-experimental-
|
|
90
|
+
"@react-router/node": "0.0.0-experimental-8d0ea8f67"
|
|
92
91
|
},
|
|
93
92
|
"devDependencies": {
|
|
94
93
|
"@types/babel__core": "^7.20.5",
|
|
@@ -117,15 +116,15 @@
|
|
|
117
116
|
"vite": "^6.0.0",
|
|
118
117
|
"wireit": "0.14.9",
|
|
119
118
|
"wrangler": "^3.28.2",
|
|
120
|
-
"react-router": "
|
|
121
|
-
"
|
|
119
|
+
"@react-router/serve": "0.0.0-experimental-8d0ea8f67",
|
|
120
|
+
"react-router": "^0.0.0-experimental-8d0ea8f67"
|
|
122
121
|
},
|
|
123
122
|
"peerDependencies": {
|
|
124
123
|
"typescript": "^5.1.0",
|
|
125
124
|
"vite": "^5.1.0 || ^6.0.0",
|
|
126
125
|
"wrangler": "^3.28.2",
|
|
127
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
128
|
-
"react-router": "^0.0.0-experimental-
|
|
126
|
+
"@react-router/serve": "^0.0.0-experimental-8d0ea8f67",
|
|
127
|
+
"react-router": "^0.0.0-experimental-8d0ea8f67"
|
|
129
128
|
},
|
|
130
129
|
"peerDependenciesMeta": {
|
|
131
130
|
"@react-router/serve": {
|
package/dist/build-X3WBF6BT.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-a334647a8
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) Remix Software Inc.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
import {
|
|
12
|
-
configRouteToBranchRoute,
|
|
13
|
-
extractPluginContext,
|
|
14
|
-
getServerBuildDirectory,
|
|
15
|
-
resolveViteConfig
|
|
16
|
-
} from "./chunk-EOMY5OBU.js";
|
|
17
|
-
import "./chunk-P4FGVWCO.js";
|
|
18
|
-
import "./chunk-MGU5SRRY.js";
|
|
19
|
-
import {
|
|
20
|
-
getVite,
|
|
21
|
-
preloadVite
|
|
22
|
-
} from "./chunk-RLHCL3MN.js";
|
|
23
|
-
import {
|
|
24
|
-
invariant
|
|
25
|
-
} from "./chunk-OKN5PVYS.js";
|
|
26
|
-
|
|
27
|
-
// vite/build.ts
|
|
28
|
-
import path from "node:path";
|
|
29
|
-
import fse from "fs-extra";
|
|
30
|
-
import colors from "picocolors";
|
|
31
|
-
function getAddressableRoutes(routes) {
|
|
32
|
-
let nonAddressableIds = /* @__PURE__ */ new Set();
|
|
33
|
-
for (let id in routes) {
|
|
34
|
-
let route = routes[id];
|
|
35
|
-
if (route.index) {
|
|
36
|
-
invariant(
|
|
37
|
-
route.parentId,
|
|
38
|
-
`Expected index route "${route.id}" to have "parentId" set`
|
|
39
|
-
);
|
|
40
|
-
nonAddressableIds.add(route.parentId);
|
|
41
|
-
}
|
|
42
|
-
if (typeof route.path !== "string" && !route.index) {
|
|
43
|
-
nonAddressableIds.add(id);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return Object.values(routes).filter(
|
|
47
|
-
(route) => !nonAddressableIds.has(route.id)
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
function getRouteBranch(routes, routeId) {
|
|
51
|
-
let branch = [];
|
|
52
|
-
let currentRouteId = routeId;
|
|
53
|
-
while (currentRouteId) {
|
|
54
|
-
let route = routes[currentRouteId];
|
|
55
|
-
invariant(route, `Missing route for ${currentRouteId}`);
|
|
56
|
-
branch.push(route);
|
|
57
|
-
currentRouteId = route.parentId;
|
|
58
|
-
}
|
|
59
|
-
return branch.reverse();
|
|
60
|
-
}
|
|
61
|
-
async function getServerBuilds(ctx) {
|
|
62
|
-
let { rootDirectory } = ctx;
|
|
63
|
-
const { routes, serverBuildFile, serverBundles, appDirectory } = ctx.reactRouterConfig;
|
|
64
|
-
let serverBuildDirectory = getServerBuildDirectory(ctx);
|
|
65
|
-
if (!serverBundles) {
|
|
66
|
-
return {
|
|
67
|
-
serverBuilds: [{ ssr: true }],
|
|
68
|
-
buildManifest: { routes }
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
let { normalizePath } = await import("vite");
|
|
72
|
-
let resolvedAppDirectory = path.resolve(rootDirectory, appDirectory);
|
|
73
|
-
let rootRelativeRoutes = Object.fromEntries(
|
|
74
|
-
Object.entries(routes).map(([id, route]) => {
|
|
75
|
-
let filePath = path.join(resolvedAppDirectory, route.file);
|
|
76
|
-
let rootRelativeFilePath = normalizePath(
|
|
77
|
-
path.relative(rootDirectory, filePath)
|
|
78
|
-
);
|
|
79
|
-
return [id, { ...route, file: rootRelativeFilePath }];
|
|
80
|
-
})
|
|
81
|
-
);
|
|
82
|
-
let buildManifest = {
|
|
83
|
-
serverBundles: {},
|
|
84
|
-
routeIdToServerBundleId: {},
|
|
85
|
-
routes: rootRelativeRoutes
|
|
86
|
-
};
|
|
87
|
-
let serverBundleBuildConfigById = /* @__PURE__ */ new Map();
|
|
88
|
-
await Promise.all(
|
|
89
|
-
getAddressableRoutes(routes).map(async (route) => {
|
|
90
|
-
let branch = getRouteBranch(routes, route.id);
|
|
91
|
-
let serverBundleId = await serverBundles({
|
|
92
|
-
branch: branch.map(
|
|
93
|
-
(route2) => configRouteToBranchRoute({
|
|
94
|
-
...route2,
|
|
95
|
-
// Ensure absolute paths are passed to the serverBundles function
|
|
96
|
-
file: path.join(resolvedAppDirectory, route2.file)
|
|
97
|
-
})
|
|
98
|
-
)
|
|
99
|
-
});
|
|
100
|
-
if (typeof serverBundleId !== "string") {
|
|
101
|
-
throw new Error(`The "serverBundles" function must return a string`);
|
|
102
|
-
}
|
|
103
|
-
if (!/^[a-zA-Z0-9-_]+$/.test(serverBundleId)) {
|
|
104
|
-
throw new Error(
|
|
105
|
-
`The "serverBundles" function must only return strings containing alphanumeric characters, hyphens and underscores.`
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
buildManifest.routeIdToServerBundleId[route.id] = serverBundleId;
|
|
109
|
-
let relativeServerBundleDirectory = path.relative(
|
|
110
|
-
rootDirectory,
|
|
111
|
-
path.join(serverBuildDirectory, serverBundleId)
|
|
112
|
-
);
|
|
113
|
-
let serverBuildConfig = serverBundleBuildConfigById.get(serverBundleId);
|
|
114
|
-
if (!serverBuildConfig) {
|
|
115
|
-
buildManifest.serverBundles[serverBundleId] = {
|
|
116
|
-
id: serverBundleId,
|
|
117
|
-
file: normalizePath(
|
|
118
|
-
path.join(relativeServerBundleDirectory, serverBuildFile)
|
|
119
|
-
)
|
|
120
|
-
};
|
|
121
|
-
serverBuildConfig = {
|
|
122
|
-
routes: {},
|
|
123
|
-
serverBundleId
|
|
124
|
-
};
|
|
125
|
-
serverBundleBuildConfigById.set(serverBundleId, serverBuildConfig);
|
|
126
|
-
}
|
|
127
|
-
for (let route2 of branch) {
|
|
128
|
-
serverBuildConfig.routes[route2.id] = route2;
|
|
129
|
-
}
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
let serverBuilds = Array.from(serverBundleBuildConfigById.values()).map(
|
|
133
|
-
(serverBundleBuildConfig) => {
|
|
134
|
-
let serverBuild = {
|
|
135
|
-
ssr: true,
|
|
136
|
-
serverBundleBuildConfig
|
|
137
|
-
};
|
|
138
|
-
return serverBuild;
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
return {
|
|
142
|
-
serverBuilds,
|
|
143
|
-
buildManifest
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
async function cleanBuildDirectory(viteConfig, ctx) {
|
|
147
|
-
let buildDirectory = ctx.reactRouterConfig.buildDirectory;
|
|
148
|
-
let isWithinRoot = () => {
|
|
149
|
-
let relativePath = path.relative(ctx.rootDirectory, buildDirectory);
|
|
150
|
-
return !relativePath.startsWith("..") && !path.isAbsolute(relativePath);
|
|
151
|
-
};
|
|
152
|
-
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
153
|
-
await fse.remove(buildDirectory);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function getViteManifestPaths(ctx, serverBuilds) {
|
|
157
|
-
let buildRelative = (pathname) => path.resolve(ctx.reactRouterConfig.buildDirectory, pathname);
|
|
158
|
-
let viteManifestPaths = [
|
|
159
|
-
"client/.vite/manifest.json",
|
|
160
|
-
...serverBuilds.map(({ serverBundleBuildConfig }) => {
|
|
161
|
-
let serverBundleId = serverBundleBuildConfig?.serverBundleId;
|
|
162
|
-
let serverBundlePath = serverBundleId ? serverBundleId + "/" : "";
|
|
163
|
-
return `server/${serverBundlePath}.vite/manifest.json`;
|
|
164
|
-
})
|
|
165
|
-
].map((srcPath) => buildRelative(srcPath));
|
|
166
|
-
return viteManifestPaths;
|
|
167
|
-
}
|
|
168
|
-
async function build(root, {
|
|
169
|
-
assetsInlineLimit,
|
|
170
|
-
clearScreen,
|
|
171
|
-
config: configFile,
|
|
172
|
-
emptyOutDir,
|
|
173
|
-
force,
|
|
174
|
-
logLevel,
|
|
175
|
-
minify,
|
|
176
|
-
mode,
|
|
177
|
-
sourcemapClient,
|
|
178
|
-
sourcemapServer
|
|
179
|
-
}) {
|
|
180
|
-
await preloadVite();
|
|
181
|
-
let viteConfig = await resolveViteConfig({ configFile, mode, root });
|
|
182
|
-
const ctx = await extractPluginContext(viteConfig);
|
|
183
|
-
if (!ctx) {
|
|
184
|
-
console.error(
|
|
185
|
-
colors.red("React Router Vite plugin not found in Vite config")
|
|
186
|
-
);
|
|
187
|
-
process.exit(1);
|
|
188
|
-
}
|
|
189
|
-
let { reactRouterConfig } = ctx;
|
|
190
|
-
let vite = getVite();
|
|
191
|
-
async function viteBuild({
|
|
192
|
-
ssr,
|
|
193
|
-
serverBundleBuildConfig
|
|
194
|
-
}) {
|
|
195
|
-
await vite.build({
|
|
196
|
-
root,
|
|
197
|
-
mode,
|
|
198
|
-
configFile,
|
|
199
|
-
build: {
|
|
200
|
-
assetsInlineLimit,
|
|
201
|
-
emptyOutDir,
|
|
202
|
-
minify,
|
|
203
|
-
ssr,
|
|
204
|
-
sourcemap: ssr ? sourcemapServer : sourcemapClient
|
|
205
|
-
},
|
|
206
|
-
optimizeDeps: { force },
|
|
207
|
-
clearScreen,
|
|
208
|
-
logLevel,
|
|
209
|
-
...serverBundleBuildConfig ? { __reactRouterServerBundleBuildConfig: serverBundleBuildConfig } : {}
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
await cleanBuildDirectory(viteConfig, ctx);
|
|
213
|
-
await viteBuild({ ssr: false });
|
|
214
|
-
let { serverBuilds, buildManifest } = await getServerBuilds(ctx);
|
|
215
|
-
await Promise.all(serverBuilds.map(viteBuild));
|
|
216
|
-
let viteManifestPaths = getViteManifestPaths(ctx, serverBuilds);
|
|
217
|
-
await Promise.all(
|
|
218
|
-
viteManifestPaths.map(async (viteManifestPath) => {
|
|
219
|
-
let manifestExists = await fse.pathExists(viteManifestPath);
|
|
220
|
-
if (!manifestExists) return;
|
|
221
|
-
if (!ctx.viteManifestEnabled) {
|
|
222
|
-
await fse.remove(viteManifestPath);
|
|
223
|
-
}
|
|
224
|
-
let viteDir = path.dirname(viteManifestPath);
|
|
225
|
-
let viteDirFiles = await fse.readdir(viteDir);
|
|
226
|
-
if (viteDirFiles.length === 0) {
|
|
227
|
-
await fse.remove(viteDir);
|
|
228
|
-
}
|
|
229
|
-
})
|
|
230
|
-
);
|
|
231
|
-
await reactRouterConfig.buildEnd?.({
|
|
232
|
-
buildManifest,
|
|
233
|
-
reactRouterConfig,
|
|
234
|
-
viteConfig
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
export {
|
|
238
|
-
build
|
|
239
|
-
};
|
package/dist/chunk-6V6JXLEB.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-a334647a8
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) Remix Software Inc.
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
// vite/profiler.ts
|
|
13
|
-
import fs from "node:fs";
|
|
14
|
-
import path from "node:path";
|
|
15
|
-
import colors from "picocolors";
|
|
16
|
-
var getSession = () => global.__reactRouter_profile_session;
|
|
17
|
-
var start = async (callback) => {
|
|
18
|
-
let inspector = await import("node:inspector").then((r) => r.default);
|
|
19
|
-
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
20
|
-
session.connect();
|
|
21
|
-
session.post("Profiler.enable", () => {
|
|
22
|
-
session.post("Profiler.start", callback);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
var profileCount = 0;
|
|
26
|
-
var stop = (log) => {
|
|
27
|
-
let session = getSession();
|
|
28
|
-
if (!session) return;
|
|
29
|
-
return new Promise((res, rej) => {
|
|
30
|
-
session.post("Profiler.stop", (err, { profile }) => {
|
|
31
|
-
if (err) return rej(err);
|
|
32
|
-
let outPath = path.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
33
|
-
fs.writeFileSync(outPath, JSON.stringify(profile));
|
|
34
|
-
log(
|
|
35
|
-
colors.yellow(
|
|
36
|
-
`CPU profile written to ${colors.white(colors.dim(outPath))}`
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
global.__reactRouter_profile_session = void 0;
|
|
40
|
-
res();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
getSession,
|
|
47
|
-
start,
|
|
48
|
-
stop
|
|
49
|
-
};
|