@netlify/vite-plugin-react-router 2.1.2 → 2.1.3
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 +7 -0
- package/dist/index.js +62 -36
- package/dist/index.mjs +51 -25
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.3](https://github.com/netlify/remix-compute/compare/vite-plugin-react-router-v2.1.2...vite-plugin-react-router-v2.1.3) (2026-01-19)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **vite-plugin-react-router:** fix prerendering by not clobbering SSR bundle entries ([#620](https://github.com/netlify/remix-compute/issues/620)) ([54851a9](https://github.com/netlify/remix-compute/commit/54851a92c4361c9987dc1cb34186bf73ddb1a38e))
|
|
9
|
+
|
|
3
10
|
## [2.1.2](https://github.com/netlify/remix-compute/compare/vite-plugin-react-router-v2.1.1...vite-plugin-react-router-v2.1.2) (2025-11-08)
|
|
4
11
|
|
|
5
12
|
|
package/dist/index.js
CHANGED
|
@@ -107,13 +107,38 @@ function createRequestHandler({
|
|
|
107
107
|
|
|
108
108
|
// src/plugin.ts
|
|
109
109
|
var import_promises = require("fs/promises");
|
|
110
|
-
var
|
|
110
|
+
var import_node_path2 = require("path");
|
|
111
111
|
var import_posix = require("path/posix");
|
|
112
112
|
var import_tinyglobby = require("tinyglobby");
|
|
113
113
|
|
|
114
114
|
// package.json
|
|
115
115
|
var name = "@netlify/vite-plugin-react-router";
|
|
116
|
-
var version = "2.1.
|
|
116
|
+
var version = "2.1.3";
|
|
117
|
+
|
|
118
|
+
// src/lib/rollup.ts
|
|
119
|
+
var import_node_path = require("path");
|
|
120
|
+
var getAliasName = (id) => {
|
|
121
|
+
const base = (0, import_node_path.basename)(id);
|
|
122
|
+
return base.slice(0, Math.max(0, base.length - (0, import_node_path.extname)(id).length));
|
|
123
|
+
};
|
|
124
|
+
var normalizeRollupInput = (input) => {
|
|
125
|
+
if (input == null) {
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
128
|
+
if (typeof input === "string") {
|
|
129
|
+
return { [getAliasName(input)]: input };
|
|
130
|
+
}
|
|
131
|
+
if (Array.isArray(input)) {
|
|
132
|
+
return Object.fromEntries(input.map((entry) => [getAliasName(entry), entry]));
|
|
133
|
+
}
|
|
134
|
+
return input;
|
|
135
|
+
};
|
|
136
|
+
var mergeRollupInput = (existing, newEntries) => {
|
|
137
|
+
return {
|
|
138
|
+
...normalizeRollupInput(existing),
|
|
139
|
+
...newEntries
|
|
140
|
+
};
|
|
141
|
+
};
|
|
117
142
|
|
|
118
143
|
// src/plugin.ts
|
|
119
144
|
var NETLIFY_FUNCTIONS_DIR = ".netlify/v1/functions";
|
|
@@ -123,7 +148,7 @@ var FUNCTION_HANDLER_CHUNK = "server";
|
|
|
123
148
|
var FUNCTION_HANDLER_MODULE_ID = "virtual:netlify-server";
|
|
124
149
|
var RESOLVED_FUNCTION_HANDLER_MODULE_ID = `\0${FUNCTION_HANDLER_MODULE_ID}`;
|
|
125
150
|
var SERVER_ENTRY_MODULE_ID = "virtual:netlify-server-entry";
|
|
126
|
-
var toPosixPath = (path) => path.split(
|
|
151
|
+
var toPosixPath = (path) => path.split(import_node_path2.sep).join(import_posix.sep);
|
|
127
152
|
var FUNCTION_HANDLER = (
|
|
128
153
|
/* js */
|
|
129
154
|
`
|
|
@@ -184,36 +209,37 @@ function netlifyPlugin(options = {}) {
|
|
|
184
209
|
let currentCommand;
|
|
185
210
|
return {
|
|
186
211
|
name: "vite-plugin-netlify-react-router",
|
|
187
|
-
config(
|
|
212
|
+
config(_config, { command, isSsrBuild }) {
|
|
188
213
|
currentCommand = command;
|
|
189
214
|
isProductionSsrBuild = isSsrBuild === true && command === "build";
|
|
190
215
|
if (isProductionSsrBuild) {
|
|
191
|
-
|
|
192
|
-
config.build.rollupOptions ??= {};
|
|
193
|
-
config.build.rollupOptions.input = {
|
|
216
|
+
const functionHandlerInput = {
|
|
194
217
|
[FUNCTION_HANDLER_CHUNK]: FUNCTION_HANDLER_MODULE_ID
|
|
195
218
|
};
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
if (edge) {
|
|
205
|
-
config.ssr = {
|
|
206
|
-
...config.ssr,
|
|
207
|
-
target: "webworker",
|
|
208
|
-
// Bundle everything except Node.js built-ins (which are supported but must use the `node:` prefix):
|
|
209
|
-
// https://docs.netlify.com/build/edge-functions/api/#runtime-environment
|
|
210
|
-
noExternal: /^(?!node:).*$/,
|
|
211
|
-
resolve: {
|
|
212
|
-
...config.resolve,
|
|
213
|
-
conditions: ["worker", "deno", "browser"]
|
|
219
|
+
const mergedInput = mergeRollupInput(_config.build?.rollupOptions?.input, functionHandlerInput);
|
|
220
|
+
const configChanges = {
|
|
221
|
+
build: {
|
|
222
|
+
rollupOptions: {
|
|
223
|
+
input: mergedInput,
|
|
224
|
+
output: {
|
|
225
|
+
entryFileNames: "[name].js"
|
|
226
|
+
}
|
|
214
227
|
}
|
|
215
|
-
}
|
|
216
|
-
|
|
228
|
+
},
|
|
229
|
+
// Additional config needed for Edge Functions if enabled
|
|
230
|
+
...edge ? {
|
|
231
|
+
ssr: {
|
|
232
|
+
target: "webworker",
|
|
233
|
+
// Bundle everything except Node.js built-ins (which are supported but must use the `node:` prefix):
|
|
234
|
+
// https://docs.netlify.com/build/edge-functions/api/#runtime-environment
|
|
235
|
+
noExternal: /^(?!node:).*$/,
|
|
236
|
+
resolve: {
|
|
237
|
+
conditions: ["worker", "deno", "browser"]
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
} : {}
|
|
241
|
+
};
|
|
242
|
+
return configChanges;
|
|
217
243
|
}
|
|
218
244
|
},
|
|
219
245
|
async resolveId(source, importer, options2) {
|
|
@@ -226,7 +252,7 @@ function netlifyPlugin(options = {}) {
|
|
|
226
252
|
if (!reactRouterDev) {
|
|
227
253
|
throw new Error("The @react-router/dev package is required for local development. Please install it.");
|
|
228
254
|
}
|
|
229
|
-
return (0,
|
|
255
|
+
return (0, import_node_path2.resolve)((0, import_node_path2.dirname)(reactRouterDev.id), "config/defaults/entry.server.node.tsx");
|
|
230
256
|
}
|
|
231
257
|
return this.resolve("@netlify/vite-plugin-react-router/entry.server.edge", importer, options2);
|
|
232
258
|
}
|
|
@@ -243,9 +269,9 @@ function netlifyPlugin(options = {}) {
|
|
|
243
269
|
// See https://rollupjs.org/plugin-development/#writebundle.
|
|
244
270
|
async writeBundle() {
|
|
245
271
|
if (isProductionSsrBuild) {
|
|
246
|
-
const handlerPath = (0,
|
|
272
|
+
const handlerPath = (0, import_node_path2.join)(resolvedConfig.build.outDir, `${FUNCTION_HANDLER_CHUNK}.js`);
|
|
247
273
|
if (edge) {
|
|
248
|
-
const clientDir = (0,
|
|
274
|
+
const clientDir = (0, import_node_path2.join)(resolvedConfig.build.outDir, "..", "client");
|
|
249
275
|
const clientFiles = await (0, import_tinyglobby.glob)("**/*", {
|
|
250
276
|
cwd: clientDir,
|
|
251
277
|
// We can't exclude entire directories because there could be `foo/bar.baz` in the
|
|
@@ -254,20 +280,20 @@ function netlifyPlugin(options = {}) {
|
|
|
254
280
|
dot: true
|
|
255
281
|
});
|
|
256
282
|
const excludedPath = ["/.netlify/*", ...clientFiles.map((file) => `/${file}`), ...additionalExcludedPaths];
|
|
257
|
-
const edgeFunctionsDir = (0,
|
|
283
|
+
const edgeFunctionsDir = (0, import_node_path2.join)(resolvedConfig.root, NETLIFY_EDGE_FUNCTIONS_DIR);
|
|
258
284
|
await (0, import_promises.mkdir)(edgeFunctionsDir, { recursive: true });
|
|
259
|
-
const relativeHandlerPath = toPosixPath((0,
|
|
285
|
+
const relativeHandlerPath = toPosixPath((0, import_node_path2.relative)(edgeFunctionsDir, handlerPath));
|
|
260
286
|
await (0, import_promises.writeFile)(
|
|
261
|
-
(0,
|
|
287
|
+
(0, import_node_path2.join)(edgeFunctionsDir, FUNCTION_FILENAME),
|
|
262
288
|
generateEdgeFunction(relativeHandlerPath, excludedPath)
|
|
263
289
|
);
|
|
264
290
|
} else {
|
|
265
|
-
const functionsDir = (0,
|
|
291
|
+
const functionsDir = (0, import_node_path2.join)(resolvedConfig.root, NETLIFY_FUNCTIONS_DIR);
|
|
266
292
|
await (0, import_promises.mkdir)(functionsDir, { recursive: true });
|
|
267
|
-
const relativeHandlerPath = toPosixPath((0,
|
|
293
|
+
const relativeHandlerPath = toPosixPath((0, import_node_path2.relative)(functionsDir, handlerPath));
|
|
268
294
|
const excludedPath = ["/.netlify/*", ...additionalExcludedPaths];
|
|
269
295
|
await (0, import_promises.writeFile)(
|
|
270
|
-
(0,
|
|
296
|
+
(0, import_node_path2.join)(functionsDir, FUNCTION_FILENAME),
|
|
271
297
|
generateNetlifyFunction(relativeHandlerPath, excludedPath)
|
|
272
298
|
);
|
|
273
299
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -12,7 +12,32 @@ import { glob } from "tinyglobby";
|
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
14
|
var name = "@netlify/vite-plugin-react-router";
|
|
15
|
-
var version = "2.1.
|
|
15
|
+
var version = "2.1.3";
|
|
16
|
+
|
|
17
|
+
// src/lib/rollup.ts
|
|
18
|
+
import { basename, extname } from "node:path";
|
|
19
|
+
var getAliasName = (id) => {
|
|
20
|
+
const base = basename(id);
|
|
21
|
+
return base.slice(0, Math.max(0, base.length - extname(id).length));
|
|
22
|
+
};
|
|
23
|
+
var normalizeRollupInput = (input) => {
|
|
24
|
+
if (input == null) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
if (typeof input === "string") {
|
|
28
|
+
return { [getAliasName(input)]: input };
|
|
29
|
+
}
|
|
30
|
+
if (Array.isArray(input)) {
|
|
31
|
+
return Object.fromEntries(input.map((entry) => [getAliasName(entry), entry]));
|
|
32
|
+
}
|
|
33
|
+
return input;
|
|
34
|
+
};
|
|
35
|
+
var mergeRollupInput = (existing, newEntries) => {
|
|
36
|
+
return {
|
|
37
|
+
...normalizeRollupInput(existing),
|
|
38
|
+
...newEntries
|
|
39
|
+
};
|
|
40
|
+
};
|
|
16
41
|
|
|
17
42
|
// src/plugin.ts
|
|
18
43
|
var NETLIFY_FUNCTIONS_DIR = ".netlify/v1/functions";
|
|
@@ -83,36 +108,37 @@ function netlifyPlugin(options = {}) {
|
|
|
83
108
|
let currentCommand;
|
|
84
109
|
return {
|
|
85
110
|
name: "vite-plugin-netlify-react-router",
|
|
86
|
-
config(
|
|
111
|
+
config(_config, { command, isSsrBuild }) {
|
|
87
112
|
currentCommand = command;
|
|
88
113
|
isProductionSsrBuild = isSsrBuild === true && command === "build";
|
|
89
114
|
if (isProductionSsrBuild) {
|
|
90
|
-
|
|
91
|
-
config.build.rollupOptions ??= {};
|
|
92
|
-
config.build.rollupOptions.input = {
|
|
115
|
+
const functionHandlerInput = {
|
|
93
116
|
[FUNCTION_HANDLER_CHUNK]: FUNCTION_HANDLER_MODULE_ID
|
|
94
117
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (edge) {
|
|
104
|
-
config.ssr = {
|
|
105
|
-
...config.ssr,
|
|
106
|
-
target: "webworker",
|
|
107
|
-
// Bundle everything except Node.js built-ins (which are supported but must use the `node:` prefix):
|
|
108
|
-
// https://docs.netlify.com/build/edge-functions/api/#runtime-environment
|
|
109
|
-
noExternal: /^(?!node:).*$/,
|
|
110
|
-
resolve: {
|
|
111
|
-
...config.resolve,
|
|
112
|
-
conditions: ["worker", "deno", "browser"]
|
|
118
|
+
const mergedInput = mergeRollupInput(_config.build?.rollupOptions?.input, functionHandlerInput);
|
|
119
|
+
const configChanges = {
|
|
120
|
+
build: {
|
|
121
|
+
rollupOptions: {
|
|
122
|
+
input: mergedInput,
|
|
123
|
+
output: {
|
|
124
|
+
entryFileNames: "[name].js"
|
|
125
|
+
}
|
|
113
126
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
127
|
+
},
|
|
128
|
+
// Additional config needed for Edge Functions if enabled
|
|
129
|
+
...edge ? {
|
|
130
|
+
ssr: {
|
|
131
|
+
target: "webworker",
|
|
132
|
+
// Bundle everything except Node.js built-ins (which are supported but must use the `node:` prefix):
|
|
133
|
+
// https://docs.netlify.com/build/edge-functions/api/#runtime-environment
|
|
134
|
+
noExternal: /^(?!node:).*$/,
|
|
135
|
+
resolve: {
|
|
136
|
+
conditions: ["worker", "deno", "browser"]
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} : {}
|
|
140
|
+
};
|
|
141
|
+
return configChanges;
|
|
116
142
|
}
|
|
117
143
|
},
|
|
118
144
|
async resolveId(source, importer, options2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/vite-plugin-react-router",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "React Router 7+ Vite plugin for Netlify",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/netlify/remix-compute#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@netlify/edge-functions": "^3.0.
|
|
56
|
-
"@netlify/functions": "^5.1.
|
|
55
|
+
"@netlify/edge-functions": "^3.0.3",
|
|
56
|
+
"@netlify/functions": "^5.1.2",
|
|
57
57
|
"isbot": "^5.1.25",
|
|
58
58
|
"tinyglobby": "^0.2.10"
|
|
59
59
|
},
|