@vercel/remix-builder 2.0.3 → 2.0.4

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/utils.js DELETED
@@ -1,333 +0,0 @@
1
- "use strict";
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 });
11
- };
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;
19
- };
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;
65
- }
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;
75
- }
76
- function isEdgeRuntime(runtime) {
77
- return runtime === "edge" || runtime === "experimental-edge";
78
- }
79
- function getResolvedRouteConfig(route, routes, configs, isHydrogen2) {
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
- }
99
- }
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 };
113
- }
114
- function calculateRouteConfigHash(config) {
115
- const str = JSON.stringify(config);
116
- return Buffer.from(str).toString("base64url");
117
- }
118
- function isLayoutRoute(routeId, routes) {
119
- return routes.some((r) => r.parentId === routeId);
120
- }
121
- function* getRouteIterator(route, routes) {
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);
131
- }
132
- function getPathFromRoute(route, routes) {
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}?`);
151
- }
152
- } else {
153
- pathParts.push(part);
154
- rePathParts.push(part);
155
- }
156
- }
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 };
162
- }
163
- function getRegExpFromPath(rePath) {
164
- const keys = [];
165
- const re = (0, import_path_to_regexp.pathToRegexp)(rePath, keys);
166
- return keys.length > 0 ? re : false;
167
- }
168
- function syncEnv(source, dest) {
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];
174
- }
175
- }
176
- return () => syncEnv(originalDest, dest);
177
- }
178
- async function chdirAndReadConfig(remixRunDevPath, dir, packageJsonPath) {
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);
200
- }
201
- }
202
- return remixConfig;
203
- }
204
- function addDependencies(cliType, names, opts = {}) {
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");
214
- }
215
- } else {
216
- args.push("add");
217
- if (opts.saveDev) {
218
- args.push("--dev");
219
- }
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");
224
- }
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");
229
- }
230
- }
231
- return (0, import_build_utils.spawnAsync)(cliType, args.concat(names), opts);
232
- }
233
- function resolveSemverMinMax(min, max, version) {
234
- const floored = import_semver.default.intersects(version, `>= ${min}`) ? version : min;
235
- return import_semver.default.intersects(floored, `<= ${max}`) ? floored : max;
236
- }
237
- async function ensureResolvable(start, base, pkgName) {
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;
246
- }
247
- } catch (err) {
248
- if (err.code !== "MODULE_NOT_FOUND") {
249
- throw err;
250
- }
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;
265
- }
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;
281
- }
282
- }
283
- throw new Error(
284
- `Failed to resolve "${pkgName}". To fix this error, add "${pkgName}" to "dependencies" in your \`package.json\` file.`
285
- );
286
- }
287
- async function ensureSymlink(target, nodeModulesDir, pkgName) {
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);
297
- }
298
- } catch (err) {
299
- if (err.code !== "ENOENT" && err.code !== "EINVAL") {
300
- throw err;
301
- }
302
- }
303
- await import_fs.promises.symlink(relativeTarget, symlinkPath);
304
- (0, import_build_utils.debug)(`Created symlink for "${pkgName}"`);
305
- }
306
- function isESM(path) {
307
- let isESM2 = false;
308
- try {
309
- _require(path);
310
- } catch (err) {
311
- isESM2 = err.code === "ERR_REQUIRE_ESM";
312
- }
313
- return isESM2;
314
- }
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
package/dist/utils.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/utils.ts"],
4
- "sourcesContent": ["import semver from 'semver';\nimport { execSync } from 'child_process';\nimport { existsSync, promises as fs } from 'fs';\nimport { basename, dirname, join, relative, resolve, sep } from 'path';\nimport { pathToRegexp, Key } from 'path-to-regexp';\nimport { debug, spawnAsync } from '@vercel/build-utils';\nimport { walkParentDirs } from '@vercel/build-utils';\nimport type {\n ConfigRoute,\n RouteManifest,\n} from '@remix-run/dev/dist/config/routes';\nimport type { RemixConfig } from '@remix-run/dev/dist/config';\nimport type { BaseFunctionConfig } from '@vercel/static-config';\nimport type {\n CliType,\n SpawnOptionsExtended,\n} from '@vercel/build-utils/dist/fs/run-user-scripts';\n\nexport const _require: typeof require = eval('require');\n\nexport interface ResolvedNodeRouteConfig {\n runtime: 'nodejs';\n regions?: string[];\n maxDuration?: number;\n memory?: number;\n}\n\nexport interface ResolvedEdgeRouteConfig {\n runtime: 'edge';\n regions?: BaseFunctionConfig['regions'];\n}\n\nexport type ResolvedRouteConfig =\n | ResolvedNodeRouteConfig\n | ResolvedEdgeRouteConfig;\n\nexport interface ResolvedRoutePaths {\n /**\n * The full URL path of the route, as will be shown\n * on the Functions tab in the deployment inspector.\n */\n path: string;\n /**\n * The full URL path of the route, but with syntax that\n * is compatible with the `path-to-regexp` module.\n */\n rePath: string;\n}\n\nconst SPLAT_PATH = '/:params*';\n\nconst entryExts = ['.js', '.jsx', '.ts', '.tsx'];\n\nexport function findEntry(dir: string, basename: string): string | undefined {\n for (const ext of entryExts) {\n const file = resolve(dir, basename + ext);\n if (existsSync(file)) return relative(dir, file);\n }\n\n return undefined;\n}\n\nconst configExts = ['.js', '.cjs', '.mjs'];\n\nexport function findConfig(dir: string, basename: string): string | undefined {\n for (const ext of configExts) {\n const name = basename + ext;\n const file = join(dir, name);\n if (existsSync(file)) return file;\n }\n\n return undefined;\n}\n\nfunction isEdgeRuntime(runtime: string): boolean {\n return runtime === 'edge' || runtime === 'experimental-edge';\n}\n\nexport function getResolvedRouteConfig(\n route: ConfigRoute,\n routes: RouteManifest,\n configs: Map<ConfigRoute, BaseFunctionConfig | null>,\n isHydrogen2: boolean\n): ResolvedRouteConfig {\n let runtime: ResolvedRouteConfig['runtime'] | undefined;\n let regions: ResolvedRouteConfig['regions'];\n let maxDuration: ResolvedNodeRouteConfig['maxDuration'];\n let memory: ResolvedNodeRouteConfig['memory'];\n\n for (const currentRoute of getRouteIterator(route, routes)) {\n const staticConfig = configs.get(currentRoute);\n if (staticConfig) {\n if (typeof runtime === 'undefined' && staticConfig.runtime) {\n runtime = isEdgeRuntime(staticConfig.runtime) ? 'edge' : 'nodejs';\n }\n if (typeof regions === 'undefined') {\n regions = staticConfig.regions;\n }\n if (typeof maxDuration === 'undefined') {\n maxDuration = staticConfig.maxDuration;\n }\n if (typeof memory === 'undefined') {\n memory = staticConfig.memory;\n }\n }\n }\n\n if (Array.isArray(regions)) {\n regions = Array.from(new Set(regions)).sort();\n }\n\n if (isHydrogen2 || runtime === 'edge') {\n return { runtime: 'edge', regions };\n }\n\n if (regions && !Array.isArray(regions)) {\n throw new Error(\n `\"regions\" for route \"${route.id}\" must be an array of strings`\n );\n }\n\n return { runtime: 'nodejs', regions, maxDuration, memory };\n}\n\nexport function calculateRouteConfigHash(config: ResolvedRouteConfig): string {\n const str = JSON.stringify(config);\n return Buffer.from(str).toString('base64url');\n}\n\nexport function isLayoutRoute(\n routeId: string,\n routes: Pick<ConfigRoute, 'id' | 'parentId'>[]\n): boolean {\n return routes.some(r => r.parentId === routeId);\n}\n\nexport function* getRouteIterator(route: ConfigRoute, routes: RouteManifest) {\n let currentRoute: ConfigRoute = route;\n do {\n yield currentRoute;\n if (currentRoute.parentId) {\n currentRoute = routes[currentRoute.parentId];\n } else {\n break;\n }\n } while (currentRoute);\n}\n\nexport function getPathFromRoute(\n route: ConfigRoute,\n routes: RouteManifest\n): ResolvedRoutePaths {\n if (\n route.id === 'root' ||\n (route.parentId === 'root' && !route.path && route.index)\n ) {\n return { path: 'index', rePath: '/index' };\n }\n\n const pathParts: string[] = [];\n const rePathParts: string[] = [];\n\n for (const currentRoute of getRouteIterator(route, routes)) {\n if (!currentRoute.path) continue;\n const currentRouteParts = currentRoute.path.split('/').reverse();\n for (const part of currentRouteParts) {\n if (part.endsWith('?')) {\n if (part.startsWith(':')) {\n // Optional path parameter\n pathParts.push(`(${part.substring(0, part.length - 1)})`);\n rePathParts.push(part);\n } else {\n // Optional static segment\n const p = `(${part.substring(0, part.length - 1)})`;\n pathParts.push(p);\n rePathParts.push(`${p}?`);\n }\n } else {\n pathParts.push(part);\n rePathParts.push(part);\n }\n }\n }\n\n const path = pathParts.reverse().join('/');\n\n // Replace \"/*\" at the end to handle \"splat routes\"\n let rePath = rePathParts.reverse().join('/');\n rePath =\n rePath === '*' ? SPLAT_PATH : `/${rePath.replace(/\\/\\*$/, SPLAT_PATH)}`;\n\n return { path, rePath };\n}\n\nexport function getRegExpFromPath(rePath: string): RegExp | false {\n const keys: Key[] = [];\n const re = pathToRegexp(rePath, keys);\n return keys.length > 0 ? re : false;\n}\n\n/**\n * Updates the `dest` process.env object to match the `source` one.\n * A function is returned to restore the the `dest` env back to how\n * it was originally.\n */\nexport function syncEnv(source: NodeJS.ProcessEnv, dest: NodeJS.ProcessEnv) {\n const originalDest = { ...dest };\n Object.assign(dest, source);\n for (const key of Object.keys(dest)) {\n if (!(key in source)) {\n delete dest[key];\n }\n }\n\n return () => syncEnv(originalDest, dest);\n}\n\nexport async function chdirAndReadConfig(\n remixRunDevPath: string,\n dir: string,\n packageJsonPath: string\n) {\n const { readConfig }: typeof import('@remix-run/dev/dist/config') =\n await import(join(remixRunDevPath, 'dist/config.js'));\n\n const originalCwd = process.cwd();\n\n // As of Remix v1.14.0, reading the config may trigger adding\n // \"isbot\" as a dependency, and `npm`/`pnpm`/`yarn` may be invoked.\n // We want to prevent that behavior, so trick `readConfig()`\n // into thinking that \"isbot\" is already installed.\n let modifiedPackageJson = false;\n const pkgRaw = await fs.readFile(packageJsonPath, 'utf8');\n const pkg = JSON.parse(pkgRaw);\n if (!pkg.dependencies?.['isbot']) {\n pkg.dependencies.isbot = 'latest';\n await fs.writeFile(packageJsonPath, JSON.stringify(pkg));\n modifiedPackageJson = true;\n }\n\n // Suppress any warnings emitted from `readConfig()` to avoid\n // printing them > 1 time. They will already be printed during\n // `remix build` when invoking the Build Command.\n const warn = console.warn;\n console.warn = debug;\n\n let remixConfig: RemixConfig;\n try {\n process.chdir(dir);\n remixConfig = await readConfig(dir);\n } finally {\n console.warn = warn;\n process.chdir(originalCwd);\n if (modifiedPackageJson) {\n await fs.writeFile(packageJsonPath, pkgRaw);\n }\n }\n\n return remixConfig;\n}\n\nexport interface AddDependenciesOptions extends SpawnOptionsExtended {\n saveDev?: boolean;\n}\n\n/**\n * Runs `npm i ${name}` / `pnpm i ${name}` / `yarn add ${name}`.\n */\nexport function addDependencies(\n cliType: CliType,\n names: string[],\n opts: AddDependenciesOptions = {}\n) {\n debug('Installing additional dependencies:');\n for (const name of names) {\n debug(` - ${name}`);\n }\n const args: string[] = [];\n\n if (cliType === 'npm' || cliType === 'pnpm') {\n args.push('install');\n if (opts.saveDev) {\n args.push('--save-dev');\n }\n } else {\n // 'yarn'\n args.push('add');\n if (opts.saveDev) {\n args.push('--dev');\n }\n const yarnVersion = execSync('yarn -v', { encoding: 'utf8' }).trim();\n const isYarnV1 = semver.satisfies(yarnVersion, '1');\n if (isYarnV1) {\n // Ignoring workspace check is only needed on Yarn v1\n args.push('--ignore-workspace-root-check');\n }\n }\n\n // Don't fail if pnpm is being run at the workspace root\n if (cliType === 'pnpm' && opts.cwd) {\n if (existsSync(join(opts.cwd, 'pnpm-workspace.yaml'))) {\n args.push('--workspace-root');\n }\n }\n\n return spawnAsync(cliType, args.concat(names), opts);\n}\n\nexport function resolveSemverMinMax(\n min: string,\n max: string,\n version: string\n): string {\n const floored = semver.intersects(version, `>= ${min}`) ? version : min;\n return semver.intersects(floored, `<= ${max}`) ? floored : max;\n}\n\nexport async function ensureResolvable(\n start: string,\n base: string,\n pkgName: string\n): Promise<string> {\n try {\n const resolvedPkgPath = _require.resolve(`${pkgName}/package.json`, {\n paths: [start],\n });\n const resolvedPath = dirname(resolvedPkgPath);\n if (!relative(base, resolvedPath).startsWith(`..${sep}`)) {\n // Resolved path is within the root of the project, so all good\n debug(`\"${pkgName}\" resolved to '${resolvedPath}'`);\n return resolvedPath;\n }\n } catch (err: any) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n }\n\n // If we got to here then `pkgName` was not resolvable up to the root\n // of the project. Try a couple symlink tricks, otherwise we'll bail.\n\n // Attempt to find the package in `node_modules/.pnpm` (pnpm)\n const pnpmDir = await walkParentDirs({\n base,\n start,\n filename: 'node_modules/.pnpm',\n });\n if (pnpmDir) {\n const prefix = `${pkgName.replace('/', '+')}@`;\n const packages = await fs.readdir(pnpmDir);\n const match = packages.find(p => p.startsWith(prefix));\n if (match) {\n const pkgDir = join(pnpmDir, match, 'node_modules', pkgName);\n await ensureSymlink(pkgDir, join(start, 'node_modules'), pkgName);\n return pkgDir;\n }\n }\n\n // Attempt to find the package in `node_modules/.store` (npm 9+ linked mode)\n const npmDir = await walkParentDirs({\n base,\n start,\n filename: 'node_modules/.store',\n });\n if (npmDir) {\n const prefix = `${basename(pkgName)}@`;\n const prefixDir = join(npmDir, dirname(pkgName));\n const packages = await fs.readdir(prefixDir);\n const match = packages.find(p => p.startsWith(prefix));\n if (match) {\n const pkgDir = join(prefixDir, match, 'node_modules', pkgName);\n await ensureSymlink(pkgDir, join(start, 'node_modules'), pkgName);\n return pkgDir;\n }\n }\n\n throw new Error(\n `Failed to resolve \"${pkgName}\". To fix this error, add \"${pkgName}\" to \"dependencies\" in your \\`package.json\\` file.`\n );\n}\n\nasync function ensureSymlink(\n target: string,\n nodeModulesDir: string,\n pkgName: string\n) {\n const symlinkPath = join(nodeModulesDir, pkgName);\n const symlinkDir = dirname(symlinkPath);\n const relativeTarget = relative(symlinkDir, target);\n\n try {\n const existingTarget = await fs.readlink(symlinkPath);\n if (existingTarget === relativeTarget) {\n // Symlink is already the expected value, so do nothing\n return;\n } else {\n // If a symlink already exists then delete it if the target doesn't match\n await fs.unlink(symlinkPath);\n }\n } catch (err: any) {\n // Ignore when path does not exist or is not a symlink\n if (err.code !== 'ENOENT' && err.code !== 'EINVAL') {\n throw err;\n }\n }\n\n await fs.symlink(relativeTarget, symlinkPath);\n debug(`Created symlink for \"${pkgName}\"`);\n}\n\nexport function isESM(path: string): boolean {\n // Figure out if the `remix.config` file is using ESM syntax\n let isESM = false;\n try {\n _require(path);\n } catch (err: any) {\n isESM = err.code === 'ERR_REQUIRE_ESM';\n }\n return isESM;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,2BAAyB;AACzB,gBAA2C;AAC3C,kBAAgE;AAChE,4BAAkC;AAClC,yBAAkC;AAClC,IAAAA,sBAA+B;AAYxB,MAAM,WAA2B,KAAK,SAAS;AA+BtD,MAAM,aAAa;AAEnB,MAAM,YAAY,CAAC,OAAO,QAAQ,OAAO,MAAM;AAExC,SAAS,UAAU,KAAaC,WAAsC;AAC3E,aAAW,OAAO,WAAW;AAC3B,UAAM,WAAO,qBAAQ,KAAKA,YAAW,GAAG;AACxC,YAAI,sBAAW,IAAI;AAAG,iBAAO,sBAAS,KAAK,IAAI;AAAA,EACjD;AAEA,SAAO;AACT;AAEA,MAAM,aAAa,CAAC,OAAO,QAAQ,MAAM;AAElC,SAAS,WAAW,KAAaA,WAAsC;AAC5E,aAAW,OAAO,YAAY;AAC5B,UAAM,OAAOA,YAAW;AACxB,UAAM,WAAO,kBAAK,KAAK,IAAI;AAC3B,YAAI,sBAAW,IAAI;AAAG,aAAO;AAAA,EAC/B;AAEA,SAAO;AACT;AAEA,SAAS,cAAc,SAA0B;AAC/C,SAAO,YAAY,UAAU,YAAY;AAC3C;AAEO,SAAS,uBACd,OACA,QACA,SACA,aACqB;AACrB,MAAI;AACJ,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,aAAW,gBAAgB,iBAAiB,OAAO,MAAM,GAAG;AAC1D,UAAM,eA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