@vercel/remix-builder 2.0.2 → 2.0.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/dist/build.js +527 -440
- package/dist/build.js.map +7 -1
- package/dist/hydrogen.js +92 -81
- package/dist/hydrogen.js.map +7 -1
- package/dist/index.js +32 -19
- package/dist/index.js.map +7 -1
- package/dist/prepare-cache.js +56 -23
- package/dist/prepare-cache.js.map +7 -1
- package/dist/utils.js +285 -301
- package/dist/utils.js.map +7 -1
- package/package.json +4 -4
package/dist/utils.js
CHANGED
|
@@ -1,349 +1,333 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
11
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
27
19
|
};
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var utils_exports = {};
|
|
30
|
+
__export(utils_exports, {
|
|
31
|
+
_require: () => _require,
|
|
32
|
+
addDependencies: () => addDependencies,
|
|
33
|
+
calculateRouteConfigHash: () => calculateRouteConfigHash,
|
|
34
|
+
chdirAndReadConfig: () => chdirAndReadConfig,
|
|
35
|
+
ensureResolvable: () => ensureResolvable,
|
|
36
|
+
findConfig: () => findConfig,
|
|
37
|
+
findEntry: () => findEntry,
|
|
38
|
+
getPathFromRoute: () => getPathFromRoute,
|
|
39
|
+
getRegExpFromPath: () => getRegExpFromPath,
|
|
40
|
+
getResolvedRouteConfig: () => getResolvedRouteConfig,
|
|
41
|
+
getRouteIterator: () => getRouteIterator,
|
|
42
|
+
isESM: () => isESM,
|
|
43
|
+
isLayoutRoute: () => isLayoutRoute,
|
|
44
|
+
resolveSemverMinMax: () => resolveSemverMinMax,
|
|
45
|
+
syncEnv: () => syncEnv
|
|
46
|
+
});
|
|
47
|
+
module.exports = __toCommonJS(utils_exports);
|
|
48
|
+
var import_semver = __toESM(require("semver"));
|
|
49
|
+
var import_child_process = require("child_process");
|
|
50
|
+
var import_fs = require("fs");
|
|
51
|
+
var import_path = require("path");
|
|
52
|
+
var import_path_to_regexp = require("path-to-regexp");
|
|
53
|
+
var import_build_utils = require("@vercel/build-utils");
|
|
54
|
+
var import_build_utils2 = require("@vercel/build-utils");
|
|
55
|
+
const _require = eval("require");
|
|
56
|
+
const SPLAT_PATH = "/:params*";
|
|
57
|
+
const entryExts = [".js", ".jsx", ".ts", ".tsx"];
|
|
58
|
+
function findEntry(dir, basename2) {
|
|
59
|
+
for (const ext of entryExts) {
|
|
60
|
+
const file = (0, import_path.resolve)(dir, basename2 + ext);
|
|
61
|
+
if ((0, import_fs.existsSync)(file))
|
|
62
|
+
return (0, import_path.relative)(dir, file);
|
|
63
|
+
}
|
|
64
|
+
return void 0;
|
|
48
65
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return undefined;
|
|
66
|
+
const configExts = [".js", ".cjs", ".mjs"];
|
|
67
|
+
function findConfig(dir, basename2) {
|
|
68
|
+
for (const ext of configExts) {
|
|
69
|
+
const name = basename2 + ext;
|
|
70
|
+
const file = (0, import_path.join)(dir, name);
|
|
71
|
+
if ((0, import_fs.existsSync)(file))
|
|
72
|
+
return file;
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
59
75
|
}
|
|
60
|
-
exports.findConfig = findConfig;
|
|
61
76
|
function isEdgeRuntime(runtime) {
|
|
62
|
-
|
|
77
|
+
return runtime === "edge" || runtime === "experimental-edge";
|
|
63
78
|
}
|
|
64
79
|
function getResolvedRouteConfig(route, routes, configs, isHydrogen2) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (Array.isArray(regions)) {
|
|
87
|
-
regions = Array.from(new Set(regions)).sort();
|
|
88
|
-
}
|
|
89
|
-
if (isHydrogen2 || runtime === 'edge') {
|
|
90
|
-
return { runtime: 'edge', regions };
|
|
91
|
-
}
|
|
92
|
-
if (regions && !Array.isArray(regions)) {
|
|
93
|
-
throw new Error(`"regions" for route "${route.id}" must be an array of strings`);
|
|
80
|
+
let runtime;
|
|
81
|
+
let regions;
|
|
82
|
+
let maxDuration;
|
|
83
|
+
let memory;
|
|
84
|
+
for (const currentRoute of getRouteIterator(route, routes)) {
|
|
85
|
+
const staticConfig = configs.get(currentRoute);
|
|
86
|
+
if (staticConfig) {
|
|
87
|
+
if (typeof runtime === "undefined" && staticConfig.runtime) {
|
|
88
|
+
runtime = isEdgeRuntime(staticConfig.runtime) ? "edge" : "nodejs";
|
|
89
|
+
}
|
|
90
|
+
if (typeof regions === "undefined") {
|
|
91
|
+
regions = staticConfig.regions;
|
|
92
|
+
}
|
|
93
|
+
if (typeof maxDuration === "undefined") {
|
|
94
|
+
maxDuration = staticConfig.maxDuration;
|
|
95
|
+
}
|
|
96
|
+
if (typeof memory === "undefined") {
|
|
97
|
+
memory = staticConfig.memory;
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
|
-
|
|
100
|
+
}
|
|
101
|
+
if (Array.isArray(regions)) {
|
|
102
|
+
regions = Array.from(new Set(regions)).sort();
|
|
103
|
+
}
|
|
104
|
+
if (isHydrogen2 || runtime === "edge") {
|
|
105
|
+
return { runtime: "edge", regions };
|
|
106
|
+
}
|
|
107
|
+
if (regions && !Array.isArray(regions)) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`"regions" for route "${route.id}" must be an array of strings`
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
return { runtime: "nodejs", regions, maxDuration, memory };
|
|
96
113
|
}
|
|
97
|
-
exports.getResolvedRouteConfig = getResolvedRouteConfig;
|
|
98
114
|
function calculateRouteConfigHash(config) {
|
|
99
|
-
|
|
100
|
-
|
|
115
|
+
const str = JSON.stringify(config);
|
|
116
|
+
return Buffer.from(str).toString("base64url");
|
|
101
117
|
}
|
|
102
|
-
exports.calculateRouteConfigHash = calculateRouteConfigHash;
|
|
103
118
|
function isLayoutRoute(routeId, routes) {
|
|
104
|
-
|
|
119
|
+
return routes.some((r) => r.parentId === routeId);
|
|
105
120
|
}
|
|
106
|
-
exports.isLayoutRoute = isLayoutRoute;
|
|
107
121
|
function* getRouteIterator(route, routes) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
} while (currentRoute);
|
|
122
|
+
let currentRoute = route;
|
|
123
|
+
do {
|
|
124
|
+
yield currentRoute;
|
|
125
|
+
if (currentRoute.parentId) {
|
|
126
|
+
currentRoute = routes[currentRoute.parentId];
|
|
127
|
+
} else {
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
} while (currentRoute);
|
|
118
131
|
}
|
|
119
|
-
exports.getRouteIterator = getRouteIterator;
|
|
120
132
|
function getPathFromRoute(route, routes) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// Optional static segment
|
|
140
|
-
const p = `(${part.substring(0, part.length - 1)})`;
|
|
141
|
-
pathParts.push(p);
|
|
142
|
-
rePathParts.push(`${p}?`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
pathParts.push(part);
|
|
147
|
-
rePathParts.push(part);
|
|
148
|
-
}
|
|
133
|
+
if (route.id === "root" || route.parentId === "root" && !route.path && route.index) {
|
|
134
|
+
return { path: "index", rePath: "/index" };
|
|
135
|
+
}
|
|
136
|
+
const pathParts = [];
|
|
137
|
+
const rePathParts = [];
|
|
138
|
+
for (const currentRoute of getRouteIterator(route, routes)) {
|
|
139
|
+
if (!currentRoute.path)
|
|
140
|
+
continue;
|
|
141
|
+
const currentRouteParts = currentRoute.path.split("/").reverse();
|
|
142
|
+
for (const part of currentRouteParts) {
|
|
143
|
+
if (part.endsWith("?")) {
|
|
144
|
+
if (part.startsWith(":")) {
|
|
145
|
+
pathParts.push(`(${part.substring(0, part.length - 1)})`);
|
|
146
|
+
rePathParts.push(part);
|
|
147
|
+
} else {
|
|
148
|
+
const p = `(${part.substring(0, part.length - 1)})`;
|
|
149
|
+
pathParts.push(p);
|
|
150
|
+
rePathParts.push(`${p}?`);
|
|
149
151
|
}
|
|
152
|
+
} else {
|
|
153
|
+
pathParts.push(part);
|
|
154
|
+
rePathParts.push(part);
|
|
155
|
+
}
|
|
150
156
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return { path, rePath };
|
|
157
|
+
}
|
|
158
|
+
const path = pathParts.reverse().join("/");
|
|
159
|
+
let rePath = rePathParts.reverse().join("/");
|
|
160
|
+
rePath = rePath === "*" ? SPLAT_PATH : `/${rePath.replace(/\/\*$/, SPLAT_PATH)}`;
|
|
161
|
+
return { path, rePath };
|
|
157
162
|
}
|
|
158
|
-
exports.getPathFromRoute = getPathFromRoute;
|
|
159
163
|
function getRegExpFromPath(rePath) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
const keys = [];
|
|
165
|
+
const re = (0, import_path_to_regexp.pathToRegexp)(rePath, keys);
|
|
166
|
+
return keys.length > 0 ? re : false;
|
|
163
167
|
}
|
|
164
|
-
exports.getRegExpFromPath = getRegExpFromPath;
|
|
165
|
-
/**
|
|
166
|
-
* Updates the `dest` process.env object to match the `source` one.
|
|
167
|
-
* A function is returned to restore the the `dest` env back to how
|
|
168
|
-
* it was originally.
|
|
169
|
-
*/
|
|
170
168
|
function syncEnv(source, dest) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
169
|
+
const originalDest = { ...dest };
|
|
170
|
+
Object.assign(dest, source);
|
|
171
|
+
for (const key of Object.keys(dest)) {
|
|
172
|
+
if (!(key in source)) {
|
|
173
|
+
delete dest[key];
|
|
177
174
|
}
|
|
178
|
-
|
|
175
|
+
}
|
|
176
|
+
return () => syncEnv(originalDest, dest);
|
|
179
177
|
}
|
|
180
|
-
exports.syncEnv = syncEnv;
|
|
181
178
|
async function chdirAndReadConfig(remixRunDevPath, dir, packageJsonPath) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
process.chdir(dir);
|
|
204
|
-
remixConfig = await readConfig(dir);
|
|
205
|
-
}
|
|
206
|
-
finally {
|
|
207
|
-
console.warn = warn;
|
|
208
|
-
process.chdir(originalCwd);
|
|
209
|
-
if (modifiedPackageJson) {
|
|
210
|
-
await fs_1.promises.writeFile(packageJsonPath, pkgRaw);
|
|
211
|
-
}
|
|
179
|
+
const { readConfig } = await import((0, import_path.join)(remixRunDevPath, "dist/config.js"));
|
|
180
|
+
const originalCwd = process.cwd();
|
|
181
|
+
let modifiedPackageJson = false;
|
|
182
|
+
const pkgRaw = await import_fs.promises.readFile(packageJsonPath, "utf8");
|
|
183
|
+
const pkg = JSON.parse(pkgRaw);
|
|
184
|
+
if (!pkg.dependencies?.["isbot"]) {
|
|
185
|
+
pkg.dependencies.isbot = "latest";
|
|
186
|
+
await import_fs.promises.writeFile(packageJsonPath, JSON.stringify(pkg));
|
|
187
|
+
modifiedPackageJson = true;
|
|
188
|
+
}
|
|
189
|
+
const warn = console.warn;
|
|
190
|
+
console.warn = import_build_utils.debug;
|
|
191
|
+
let remixConfig;
|
|
192
|
+
try {
|
|
193
|
+
process.chdir(dir);
|
|
194
|
+
remixConfig = await readConfig(dir);
|
|
195
|
+
} finally {
|
|
196
|
+
console.warn = warn;
|
|
197
|
+
process.chdir(originalCwd);
|
|
198
|
+
if (modifiedPackageJson) {
|
|
199
|
+
await import_fs.promises.writeFile(packageJsonPath, pkgRaw);
|
|
212
200
|
}
|
|
213
|
-
|
|
201
|
+
}
|
|
202
|
+
return remixConfig;
|
|
214
203
|
}
|
|
215
|
-
exports.chdirAndReadConfig = chdirAndReadConfig;
|
|
216
|
-
/**
|
|
217
|
-
* Runs `npm i ${name}` / `pnpm i ${name}` / `yarn add ${name}`.
|
|
218
|
-
*/
|
|
219
204
|
function addDependencies(cliType, names, opts = {}) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
205
|
+
(0, import_build_utils.debug)("Installing additional dependencies:");
|
|
206
|
+
for (const name of names) {
|
|
207
|
+
(0, import_build_utils.debug)(` - ${name}`);
|
|
208
|
+
}
|
|
209
|
+
const args = [];
|
|
210
|
+
if (cliType === "npm" || cliType === "pnpm") {
|
|
211
|
+
args.push("install");
|
|
212
|
+
if (opts.saveDev) {
|
|
213
|
+
args.push("--save-dev");
|
|
223
214
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
args.push('--save-dev');
|
|
229
|
-
}
|
|
215
|
+
} else {
|
|
216
|
+
args.push("add");
|
|
217
|
+
if (opts.saveDev) {
|
|
218
|
+
args.push("--dev");
|
|
230
219
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
args.push('--dev');
|
|
236
|
-
}
|
|
237
|
-
const yarnVersion = (0, child_process_1.execSync)('yarn -v', { encoding: 'utf8' }).trim();
|
|
238
|
-
const isYarnV1 = semver_1.default.satisfies(yarnVersion, '1');
|
|
239
|
-
if (isYarnV1) {
|
|
240
|
-
// Ignoring workspace check is only needed on Yarn v1
|
|
241
|
-
args.push('--ignore-workspace-root-check');
|
|
242
|
-
}
|
|
220
|
+
const yarnVersion = (0, import_child_process.execSync)("yarn -v", { encoding: "utf8" }).trim();
|
|
221
|
+
const isYarnV1 = import_semver.default.satisfies(yarnVersion, "1");
|
|
222
|
+
if (isYarnV1) {
|
|
223
|
+
args.push("--ignore-workspace-root-check");
|
|
243
224
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
225
|
+
}
|
|
226
|
+
if (cliType === "pnpm" && opts.cwd) {
|
|
227
|
+
if ((0, import_fs.existsSync)((0, import_path.join)(opts.cwd, "pnpm-workspace.yaml"))) {
|
|
228
|
+
args.push("--workspace-root");
|
|
249
229
|
}
|
|
250
|
-
|
|
230
|
+
}
|
|
231
|
+
return (0, import_build_utils.spawnAsync)(cliType, args.concat(names), opts);
|
|
251
232
|
}
|
|
252
|
-
exports.addDependencies = addDependencies;
|
|
253
233
|
function resolveSemverMinMax(min, max, version) {
|
|
254
|
-
|
|
255
|
-
|
|
234
|
+
const floored = import_semver.default.intersects(version, `>= ${min}`) ? version : min;
|
|
235
|
+
return import_semver.default.intersects(floored, `<= ${max}`) ? floored : max;
|
|
256
236
|
}
|
|
257
|
-
exports.resolveSemverMinMax = resolveSemverMinMax;
|
|
258
237
|
async function ensureResolvable(start, base, pkgName) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return resolvedPath;
|
|
268
|
-
}
|
|
238
|
+
try {
|
|
239
|
+
const resolvedPkgPath = _require.resolve(`${pkgName}/package.json`, {
|
|
240
|
+
paths: [start]
|
|
241
|
+
});
|
|
242
|
+
const resolvedPath = (0, import_path.dirname)(resolvedPkgPath);
|
|
243
|
+
if (!(0, import_path.relative)(base, resolvedPath).startsWith(`..${import_path.sep}`)) {
|
|
244
|
+
(0, import_build_utils.debug)(`"${pkgName}" resolved to '${resolvedPath}'`);
|
|
245
|
+
return resolvedPath;
|
|
269
246
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
247
|
+
} catch (err) {
|
|
248
|
+
if (err.code !== "MODULE_NOT_FOUND") {
|
|
249
|
+
throw err;
|
|
274
250
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
await ensureSymlink(pkgDir, (0, path_1.join)(start, 'node_modules'), pkgName);
|
|
290
|
-
return pkgDir;
|
|
291
|
-
}
|
|
251
|
+
}
|
|
252
|
+
const pnpmDir = await (0, import_build_utils2.walkParentDirs)({
|
|
253
|
+
base,
|
|
254
|
+
start,
|
|
255
|
+
filename: "node_modules/.pnpm"
|
|
256
|
+
});
|
|
257
|
+
if (pnpmDir) {
|
|
258
|
+
const prefix = `${pkgName.replace("/", "+")}@`;
|
|
259
|
+
const packages = await import_fs.promises.readdir(pnpmDir);
|
|
260
|
+
const match = packages.find((p) => p.startsWith(prefix));
|
|
261
|
+
if (match) {
|
|
262
|
+
const pkgDir = (0, import_path.join)(pnpmDir, match, "node_modules", pkgName);
|
|
263
|
+
await ensureSymlink(pkgDir, (0, import_path.join)(start, "node_modules"), pkgName);
|
|
264
|
+
return pkgDir;
|
|
292
265
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
266
|
+
}
|
|
267
|
+
const npmDir = await (0, import_build_utils2.walkParentDirs)({
|
|
268
|
+
base,
|
|
269
|
+
start,
|
|
270
|
+
filename: "node_modules/.store"
|
|
271
|
+
});
|
|
272
|
+
if (npmDir) {
|
|
273
|
+
const prefix = `${(0, import_path.basename)(pkgName)}@`;
|
|
274
|
+
const prefixDir = (0, import_path.join)(npmDir, (0, import_path.dirname)(pkgName));
|
|
275
|
+
const packages = await import_fs.promises.readdir(prefixDir);
|
|
276
|
+
const match = packages.find((p) => p.startsWith(prefix));
|
|
277
|
+
if (match) {
|
|
278
|
+
const pkgDir = (0, import_path.join)(prefixDir, match, "node_modules", pkgName);
|
|
279
|
+
await ensureSymlink(pkgDir, (0, import_path.join)(start, "node_modules"), pkgName);
|
|
280
|
+
return pkgDir;
|
|
309
281
|
}
|
|
310
|
-
|
|
282
|
+
}
|
|
283
|
+
throw new Error(
|
|
284
|
+
`Failed to resolve "${pkgName}". To fix this error, add "${pkgName}" to "dependencies" in your \`package.json\` file.`
|
|
285
|
+
);
|
|
311
286
|
}
|
|
312
|
-
exports.ensureResolvable = ensureResolvable;
|
|
313
287
|
async function ensureSymlink(target, nodeModulesDir, pkgName) {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
else {
|
|
324
|
-
// If a symlink already exists then delete it if the target doesn't match
|
|
325
|
-
await fs_1.promises.unlink(symlinkPath);
|
|
326
|
-
}
|
|
288
|
+
const symlinkPath = (0, import_path.join)(nodeModulesDir, pkgName);
|
|
289
|
+
const symlinkDir = (0, import_path.dirname)(symlinkPath);
|
|
290
|
+
const relativeTarget = (0, import_path.relative)(symlinkDir, target);
|
|
291
|
+
try {
|
|
292
|
+
const existingTarget = await import_fs.promises.readlink(symlinkPath);
|
|
293
|
+
if (existingTarget === relativeTarget) {
|
|
294
|
+
return;
|
|
295
|
+
} else {
|
|
296
|
+
await import_fs.promises.unlink(symlinkPath);
|
|
327
297
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
throw err;
|
|
332
|
-
}
|
|
298
|
+
} catch (err) {
|
|
299
|
+
if (err.code !== "ENOENT" && err.code !== "EINVAL") {
|
|
300
|
+
throw err;
|
|
333
301
|
}
|
|
334
|
-
|
|
335
|
-
|
|
302
|
+
}
|
|
303
|
+
await import_fs.promises.symlink(relativeTarget, symlinkPath);
|
|
304
|
+
(0, import_build_utils.debug)(`Created symlink for "${pkgName}"`);
|
|
336
305
|
}
|
|
337
306
|
function isESM(path) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
}
|
|
346
|
-
return isESM;
|
|
307
|
+
let isESM2 = false;
|
|
308
|
+
try {
|
|
309
|
+
_require(path);
|
|
310
|
+
} catch (err) {
|
|
311
|
+
isESM2 = err.code === "ERR_REQUIRE_ESM";
|
|
312
|
+
}
|
|
313
|
+
return isESM2;
|
|
347
314
|
}
|
|
348
|
-
|
|
349
|
-
|
|
315
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
316
|
+
0 && (module.exports = {
|
|
317
|
+
_require,
|
|
318
|
+
addDependencies,
|
|
319
|
+
calculateRouteConfigHash,
|
|
320
|
+
chdirAndReadConfig,
|
|
321
|
+
ensureResolvable,
|
|
322
|
+
findConfig,
|
|
323
|
+
findEntry,
|
|
324
|
+
getPathFromRoute,
|
|
325
|
+
getRegExpFromPath,
|
|
326
|
+
getResolvedRouteConfig,
|
|
327
|
+
getRouteIterator,
|
|
328
|
+
isESM,
|
|
329
|
+
isLayoutRoute,
|
|
330
|
+
resolveSemverMinMax,
|
|
331
|
+
syncEnv
|
|
332
|
+
});
|
|
333
|
+
//# sourceMappingURL=utils.js.map
|