@vercel/remix-builder 5.8.0 → 5.8.2
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/dist/index.js +52 -7
- package/package.json +3 -5
package/dist/index.js
CHANGED
|
@@ -2630,6 +2630,17 @@ function getRegExpFromPath(rePath) {
|
|
|
2630
2630
|
const re = pathToRegexp("923", rePath, keys);
|
|
2631
2631
|
return keys.length > 0 ? re : false;
|
|
2632
2632
|
}
|
|
2633
|
+
function getReactRouterDataPaths(path) {
|
|
2634
|
+
const paths = [`${path}.data`];
|
|
2635
|
+
if (path === "index") {
|
|
2636
|
+
paths.push("_root.data");
|
|
2637
|
+
}
|
|
2638
|
+
return paths;
|
|
2639
|
+
}
|
|
2640
|
+
function findPrerenderedHtmlFile(path, staticFileKeys) {
|
|
2641
|
+
const candidates = path === "index" ? ["index.html"] : [`${path}.html`, `${path}/index.html`];
|
|
2642
|
+
return candidates.find((c) => staticFileKeys.has(c));
|
|
2643
|
+
}
|
|
2633
2644
|
async function chdirAndReadConfig(remixRunDevPath, dir, packageJsonPath) {
|
|
2634
2645
|
const { readConfig } = await import((0, import_path.join)(remixRunDevPath, "dist/config.js"));
|
|
2635
2646
|
const originalCwd = process.cwd();
|
|
@@ -3152,11 +3163,10 @@ var build = async ({
|
|
|
3152
3163
|
}
|
|
3153
3164
|
const output = staticFiles;
|
|
3154
3165
|
const assetsDir = viteConfig?.build?.assetsDir || "assets";
|
|
3155
|
-
const
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
];
|
|
3166
|
+
const isReactRouter = frameworkSettings.slug === "react-router";
|
|
3167
|
+
const staticFileKeys = new Set(Object.keys(staticFiles));
|
|
3168
|
+
const prerenderRewrites = [];
|
|
3169
|
+
const routes = [];
|
|
3160
3170
|
for (const [id, functionId] of Object.entries(
|
|
3161
3171
|
buildManifest.routeIdToServerBundleId ?? {}
|
|
3162
3172
|
)) {
|
|
@@ -3165,19 +3175,46 @@ var build = async ({
|
|
|
3165
3175
|
if (!path) {
|
|
3166
3176
|
continue;
|
|
3167
3177
|
}
|
|
3178
|
+
if (isReactRouter) {
|
|
3179
|
+
const htmlFile = findPrerenderedHtmlFile(path, staticFileKeys);
|
|
3180
|
+
if (htmlFile) {
|
|
3181
|
+
if (path !== "index") {
|
|
3182
|
+
prerenderRewrites.push({
|
|
3183
|
+
src: `^/${path}/?$`,
|
|
3184
|
+
dest: `/${htmlFile}`
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
continue;
|
|
3188
|
+
}
|
|
3189
|
+
}
|
|
3168
3190
|
const func = functionsMap.get(functionId);
|
|
3169
3191
|
if (!func) {
|
|
3170
3192
|
throw new Error(`Could not determine server bundle for "${id}"`);
|
|
3171
3193
|
}
|
|
3172
3194
|
output[path] = func;
|
|
3195
|
+
if (isReactRouter) {
|
|
3196
|
+
for (const dataPath of getReactRouterDataPaths(path)) {
|
|
3197
|
+
output[dataPath] = func;
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3173
3200
|
const re = getRegExpFromPath(rePath);
|
|
3174
3201
|
if (re) {
|
|
3202
|
+
if (isReactRouter) {
|
|
3203
|
+
const reData = getRegExpFromPath(`${rePath}.data`);
|
|
3204
|
+
if (reData) {
|
|
3205
|
+
routes.push({
|
|
3206
|
+
src: reData.source,
|
|
3207
|
+
dest: `${path}.data`
|
|
3208
|
+
});
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3175
3211
|
routes.push({
|
|
3176
3212
|
src: re.source,
|
|
3177
3213
|
dest: path
|
|
3178
3214
|
});
|
|
3179
3215
|
}
|
|
3180
3216
|
}
|
|
3217
|
+
routes.unshift(...prerenderRewrites, { handle: "filesystem" });
|
|
3181
3218
|
routes.push({
|
|
3182
3219
|
src: "/(.*)",
|
|
3183
3220
|
dest: "/"
|
|
@@ -3190,7 +3227,11 @@ var build = async ({
|
|
|
3190
3227
|
headers: { "cache-control": "public, max-age=31536000, immutable" },
|
|
3191
3228
|
continue: true
|
|
3192
3229
|
});
|
|
3193
|
-
return {
|
|
3230
|
+
return {
|
|
3231
|
+
routes,
|
|
3232
|
+
output,
|
|
3233
|
+
framework: { slug: "remix", version: frameworkVersion }
|
|
3234
|
+
};
|
|
3194
3235
|
};
|
|
3195
3236
|
async function traceEdgeFiles({
|
|
3196
3237
|
handlerPath,
|
|
@@ -3847,7 +3888,11 @@ module.exports = config;`;
|
|
|
3847
3888
|
headers: { "cache-control": "public, max-age=31536000, immutable" },
|
|
3848
3889
|
continue: true
|
|
3849
3890
|
});
|
|
3850
|
-
return {
|
|
3891
|
+
return {
|
|
3892
|
+
routes,
|
|
3893
|
+
output,
|
|
3894
|
+
framework: { slug: "remix", version: remixVersion }
|
|
3895
|
+
};
|
|
3851
3896
|
};
|
|
3852
3897
|
function hasScript2(scriptName, pkg) {
|
|
3853
3898
|
const scripts = pkg && pkg.scripts || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/remix-builder",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -23,19 +23,17 @@
|
|
|
23
23
|
"@vercel/static-config": "3.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/jest": "27.5.1",
|
|
27
26
|
"@types/node": "20.11.0",
|
|
28
27
|
"@types/semver": "7.3.13",
|
|
29
28
|
"glob": "10.3.16",
|
|
30
|
-
"jest-junit": "16.0.0",
|
|
31
29
|
"semver": "7.5.2",
|
|
32
30
|
"vitest": "2.0.1",
|
|
33
|
-
"@vercel/build-utils": "13.
|
|
31
|
+
"@vercel/build-utils": "13.26.0"
|
|
34
32
|
},
|
|
35
33
|
"VERCEL_REMIX_RUN_DEV_MAX_VERSION": "2.16.6",
|
|
36
34
|
"scripts": {
|
|
37
35
|
"build": "node ../../utils/build-builder.mjs",
|
|
38
|
-
"test": "
|
|
36
|
+
"test": "vitest run --config ../../vitest.config.mts",
|
|
39
37
|
"vitest-run": "vitest -c ../../vitest.config.mts",
|
|
40
38
|
"vitest-unit": "glob --absolute 'test/unit.*.test.ts'",
|
|
41
39
|
"vitest-e2e": "glob --absolute 'test/integration-*.test.ts'",
|