@netlify/vite-plugin-react-router 3.0.0 → 3.1.0-next.1
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 +42 -4
- package/dist/index.mjs +43 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -113,7 +113,7 @@ var import_tinyglobby = require("tinyglobby");
|
|
|
113
113
|
|
|
114
114
|
// package.json
|
|
115
115
|
var name = "@netlify/vite-plugin-react-router";
|
|
116
|
-
var version = "3.0.
|
|
116
|
+
var version = "3.1.0-next.1";
|
|
117
117
|
|
|
118
118
|
// src/lib/rollup.ts
|
|
119
119
|
var import_node_path = require("path");
|
|
@@ -149,6 +149,26 @@ var FUNCTION_HANDLER_MODULE_ID = "virtual:netlify-server";
|
|
|
149
149
|
var RESOLVED_FUNCTION_HANDLER_MODULE_ID = `\0${FUNCTION_HANDLER_MODULE_ID}`;
|
|
150
150
|
var SERVER_ENTRY_MODULE_ID = "virtual:netlify-server-entry";
|
|
151
151
|
var toPosixPath = (path) => path.split(import_node_path2.sep).join(import_posix.sep);
|
|
152
|
+
var ALLOWED_USER_EDGE_FUNCTION_HANDLER_FILENAMES = [
|
|
153
|
+
"server.ts",
|
|
154
|
+
"server.mts",
|
|
155
|
+
"server.cts",
|
|
156
|
+
"server.mjs",
|
|
157
|
+
"server.cjs",
|
|
158
|
+
"server.js"
|
|
159
|
+
];
|
|
160
|
+
var findUserEdgeFunctionHandlerFile = async (root) => {
|
|
161
|
+
for (const filename of ALLOWED_USER_EDGE_FUNCTION_HANDLER_FILENAMES) {
|
|
162
|
+
try {
|
|
163
|
+
await (0, import_promises.access)((0, import_node_path2.join)(root, filename));
|
|
164
|
+
return filename;
|
|
165
|
+
} catch {
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
throw new Error(
|
|
169
|
+
"Your Hydrogen site must include a `server.ts` (or js/mjs/cjs/mts/cts) file at the root to deploy to Netlify. See https://github.com/netlify/hydrogen-template."
|
|
170
|
+
);
|
|
171
|
+
};
|
|
152
172
|
var FUNCTION_HANDLER = (
|
|
153
173
|
/* js */
|
|
154
174
|
`
|
|
@@ -207,6 +227,7 @@ function netlifyPlugin(options = {}) {
|
|
|
207
227
|
let resolvedConfig;
|
|
208
228
|
let isProductionSsrBuild = false;
|
|
209
229
|
let currentCommand;
|
|
230
|
+
let isHydrogenSite = false;
|
|
210
231
|
return {
|
|
211
232
|
name: "vite-plugin-netlify-react-router",
|
|
212
233
|
config(_config, { command, isSsrBuild }) {
|
|
@@ -222,7 +243,9 @@ function netlifyPlugin(options = {}) {
|
|
|
222
243
|
rollupOptions: {
|
|
223
244
|
input: mergedInput,
|
|
224
245
|
output: {
|
|
225
|
-
|
|
246
|
+
// NOTE: must use function syntax here to work around Shopify CLI reading
|
|
247
|
+
// the config value literally (i.e. trying to stat `[name].js` as a filename).
|
|
248
|
+
entryFileNames: () => "[name].js"
|
|
226
249
|
}
|
|
227
250
|
}
|
|
228
251
|
},
|
|
@@ -243,6 +266,11 @@ function netlifyPlugin(options = {}) {
|
|
|
243
266
|
}
|
|
244
267
|
},
|
|
245
268
|
async resolveId(source, importer, options2) {
|
|
269
|
+
if (isHydrogenSite && edge) {
|
|
270
|
+
if (source === FUNCTION_HANDLER_MODULE_ID || source === SERVER_ENTRY_MODULE_ID) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
246
274
|
if (source === FUNCTION_HANDLER_MODULE_ID) {
|
|
247
275
|
return RESOLVED_FUNCTION_HANDLER_MODULE_ID;
|
|
248
276
|
}
|
|
@@ -263,8 +291,18 @@ function netlifyPlugin(options = {}) {
|
|
|
263
291
|
return edge ? EDGE_FUNCTION_HANDLER : FUNCTION_HANDLER;
|
|
264
292
|
}
|
|
265
293
|
},
|
|
266
|
-
|
|
267
|
-
|
|
294
|
+
configResolved: {
|
|
295
|
+
order: "pre",
|
|
296
|
+
async handler(config) {
|
|
297
|
+
resolvedConfig = config;
|
|
298
|
+
isHydrogenSite = config.plugins.some((plugin) => plugin.name === "hydrogen:main");
|
|
299
|
+
if (isHydrogenSite && edge && isProductionSsrBuild) {
|
|
300
|
+
const userServerFile = await findUserEdgeFunctionHandlerFile(config.root);
|
|
301
|
+
if (config.build?.rollupOptions?.input && typeof config.build.rollupOptions.input === "object" && !Array.isArray(config.build.rollupOptions.input)) {
|
|
302
|
+
config.build.rollupOptions.input[FUNCTION_HANDLER_CHUNK] = userServerFile;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
268
306
|
},
|
|
269
307
|
// See https://rollupjs.org/plugin-development/#writebundle.
|
|
270
308
|
async writeBundle() {
|
package/dist/index.mjs
CHANGED
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
import "./chunk-J5PMA2AP.mjs";
|
|
6
6
|
|
|
7
7
|
// src/plugin.ts
|
|
8
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
8
|
+
import { access, mkdir, writeFile } from "node:fs/promises";
|
|
9
9
|
import { dirname, join, relative, resolve, sep } from "node:path";
|
|
10
10
|
import { sep as posixSep } from "node:path/posix";
|
|
11
11
|
import { glob } from "tinyglobby";
|
|
12
12
|
|
|
13
13
|
// package.json
|
|
14
14
|
var name = "@netlify/vite-plugin-react-router";
|
|
15
|
-
var version = "3.0.
|
|
15
|
+
var version = "3.1.0-next.1";
|
|
16
16
|
|
|
17
17
|
// src/lib/rollup.ts
|
|
18
18
|
import { basename, extname } from "node:path";
|
|
@@ -48,6 +48,26 @@ var FUNCTION_HANDLER_MODULE_ID = "virtual:netlify-server";
|
|
|
48
48
|
var RESOLVED_FUNCTION_HANDLER_MODULE_ID = `\0${FUNCTION_HANDLER_MODULE_ID}`;
|
|
49
49
|
var SERVER_ENTRY_MODULE_ID = "virtual:netlify-server-entry";
|
|
50
50
|
var toPosixPath = (path) => path.split(sep).join(posixSep);
|
|
51
|
+
var ALLOWED_USER_EDGE_FUNCTION_HANDLER_FILENAMES = [
|
|
52
|
+
"server.ts",
|
|
53
|
+
"server.mts",
|
|
54
|
+
"server.cts",
|
|
55
|
+
"server.mjs",
|
|
56
|
+
"server.cjs",
|
|
57
|
+
"server.js"
|
|
58
|
+
];
|
|
59
|
+
var findUserEdgeFunctionHandlerFile = async (root) => {
|
|
60
|
+
for (const filename of ALLOWED_USER_EDGE_FUNCTION_HANDLER_FILENAMES) {
|
|
61
|
+
try {
|
|
62
|
+
await access(join(root, filename));
|
|
63
|
+
return filename;
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw new Error(
|
|
68
|
+
"Your Hydrogen site must include a `server.ts` (or js/mjs/cjs/mts/cts) file at the root to deploy to Netlify. See https://github.com/netlify/hydrogen-template."
|
|
69
|
+
);
|
|
70
|
+
};
|
|
51
71
|
var FUNCTION_HANDLER = (
|
|
52
72
|
/* js */
|
|
53
73
|
`
|
|
@@ -106,6 +126,7 @@ function netlifyPlugin(options = {}) {
|
|
|
106
126
|
let resolvedConfig;
|
|
107
127
|
let isProductionSsrBuild = false;
|
|
108
128
|
let currentCommand;
|
|
129
|
+
let isHydrogenSite = false;
|
|
109
130
|
return {
|
|
110
131
|
name: "vite-plugin-netlify-react-router",
|
|
111
132
|
config(_config, { command, isSsrBuild }) {
|
|
@@ -121,7 +142,9 @@ function netlifyPlugin(options = {}) {
|
|
|
121
142
|
rollupOptions: {
|
|
122
143
|
input: mergedInput,
|
|
123
144
|
output: {
|
|
124
|
-
|
|
145
|
+
// NOTE: must use function syntax here to work around Shopify CLI reading
|
|
146
|
+
// the config value literally (i.e. trying to stat `[name].js` as a filename).
|
|
147
|
+
entryFileNames: () => "[name].js"
|
|
125
148
|
}
|
|
126
149
|
}
|
|
127
150
|
},
|
|
@@ -142,6 +165,11 @@ function netlifyPlugin(options = {}) {
|
|
|
142
165
|
}
|
|
143
166
|
},
|
|
144
167
|
async resolveId(source, importer, options2) {
|
|
168
|
+
if (isHydrogenSite && edge) {
|
|
169
|
+
if (source === FUNCTION_HANDLER_MODULE_ID || source === SERVER_ENTRY_MODULE_ID) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
145
173
|
if (source === FUNCTION_HANDLER_MODULE_ID) {
|
|
146
174
|
return RESOLVED_FUNCTION_HANDLER_MODULE_ID;
|
|
147
175
|
}
|
|
@@ -162,8 +190,18 @@ function netlifyPlugin(options = {}) {
|
|
|
162
190
|
return edge ? EDGE_FUNCTION_HANDLER : FUNCTION_HANDLER;
|
|
163
191
|
}
|
|
164
192
|
},
|
|
165
|
-
|
|
166
|
-
|
|
193
|
+
configResolved: {
|
|
194
|
+
order: "pre",
|
|
195
|
+
async handler(config) {
|
|
196
|
+
resolvedConfig = config;
|
|
197
|
+
isHydrogenSite = config.plugins.some((plugin) => plugin.name === "hydrogen:main");
|
|
198
|
+
if (isHydrogenSite && edge && isProductionSsrBuild) {
|
|
199
|
+
const userServerFile = await findUserEdgeFunctionHandlerFile(config.root);
|
|
200
|
+
if (config.build?.rollupOptions?.input && typeof config.build.rollupOptions.input === "object" && !Array.isArray(config.build.rollupOptions.input)) {
|
|
201
|
+
config.build.rollupOptions.input[FUNCTION_HANDLER_CHUNK] = userServerFile;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
167
205
|
},
|
|
168
206
|
// See https://rollupjs.org/plugin-development/#writebundle.
|
|
169
207
|
async writeBundle() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/vite-plugin-react-router",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.0-next.1",
|
|
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.4",
|
|
56
|
+
"@netlify/functions": "^5.1.3",
|
|
57
57
|
"isbot": "^5.1.25",
|
|
58
58
|
"tinyglobby": "^0.2.10"
|
|
59
59
|
},
|