@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/remix-builder",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
@@ -14,11 +14,8 @@
14
14
  "defaults"
15
15
  ],
16
16
  "dependencies": {
17
- "@vercel/build-utils": "7.1.1",
18
17
  "@vercel/nft": "0.22.5",
19
18
  "@vercel/static-config": "3.0.0",
20
- "path-to-regexp": "6.2.1",
21
- "semver": "7.5.2",
22
19
  "ts-morph": "12.0.0"
23
20
  },
24
21
  "devDependencies": {
@@ -26,10 +23,13 @@
26
23
  "@types/jest": "27.5.1",
27
24
  "@types/node": "14.18.33",
28
25
  "@types/semver": "7.3.13",
29
- "jest-junit": "16.0.0"
26
+ "@vercel/build-utils": "7.2.0",
27
+ "jest-junit": "16.0.0",
28
+ "path-to-regexp": "6.2.1",
29
+ "semver": "7.5.2"
30
30
  },
31
31
  "scripts": {
32
- "build": "node ../../utils/build.mjs",
32
+ "build": "node ../../utils/build-builder.mjs",
33
33
  "test": "jest --reporters=default --reporters=jest-junit --env node --verbose --bail --runInBand",
34
34
  "test-unit": "pnpm test test/unit.*test.*",
35
35
  "test-e2e": "pnpm test test/integration.test.ts"
package/dist/build.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { BuildV2 } from '@vercel/build-utils';
2
- export declare const build: BuildV2;
package/dist/build.js DELETED
@@ -1,567 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var build_exports = {};
20
- __export(build_exports, {
21
- build: () => build
22
- });
23
- module.exports = __toCommonJS(build_exports);
24
- var import_ts_morph = require("ts-morph");
25
- var import_fs = require("fs");
26
- var import_path = require("path");
27
- var import_build_utils = require("@vercel/build-utils");
28
- var import_static_config = require("@vercel/static-config");
29
- var import_nft = require("@vercel/nft");
30
- var import_utils = require("./utils");
31
- var import_hydrogen = require("./hydrogen");
32
- const remixBuilderPkg = JSON.parse(
33
- (0, import_fs.readFileSync)((0, import_path.join)(__dirname, "../package.json"), "utf8")
34
- );
35
- const remixRunDevForkVersion = remixBuilderPkg.devDependencies["@remix-run/dev"];
36
- const DEFAULTS_PATH = (0, import_path.join)(__dirname, "../defaults");
37
- const edgeServerSrcPromise = import_fs.promises.readFile(
38
- (0, import_path.join)(DEFAULTS_PATH, "server-edge.mjs"),
39
- "utf-8"
40
- );
41
- const nodeServerSrcPromise = import_fs.promises.readFile(
42
- (0, import_path.join)(DEFAULTS_PATH, "server-node.mjs"),
43
- "utf-8"
44
- );
45
- const VERCEL_REMIX_MIN_VERSION = "1.10.0";
46
- const REMIX_RUN_DEV_MIN_VERSION = "1.15.0";
47
- const REMIX_RUN_DEV_MAX_VERSION = remixRunDevForkVersion.slice(
48
- remixRunDevForkVersion.lastIndexOf("@") + 1
49
- );
50
- const build = async ({
51
- entrypoint,
52
- files,
53
- workPath,
54
- repoRootPath,
55
- config,
56
- meta = {}
57
- }) => {
58
- const { installCommand, buildCommand } = config;
59
- await (0, import_build_utils.download)(files, workPath, meta);
60
- const mountpoint = (0, import_path.dirname)(entrypoint);
61
- const entrypointFsDirname = (0, import_path.join)(workPath, mountpoint);
62
- const nodeVersion = await (0, import_build_utils.getNodeVersion)(
63
- entrypointFsDirname,
64
- void 0,
65
- config,
66
- meta
67
- );
68
- const { cliType, packageJsonPath, lockfileVersion } = await (0, import_build_utils.scanParentDirs)(
69
- entrypointFsDirname
70
- );
71
- if (!packageJsonPath) {
72
- throw new Error("Failed to locate `package.json` file in your project");
73
- }
74
- const pkgRaw = await import_fs.promises.readFile(packageJsonPath, "utf8");
75
- const pkg = JSON.parse(pkgRaw);
76
- const spawnOpts = (0, import_build_utils.getSpawnOptions)(meta, nodeVersion);
77
- if (!spawnOpts.env) {
78
- spawnOpts.env = {};
79
- }
80
- spawnOpts.env = (0, import_build_utils.getEnvForPackageManager)({
81
- cliType,
82
- lockfileVersion,
83
- nodeVersion,
84
- env: spawnOpts.env
85
- });
86
- if (typeof installCommand === "string") {
87
- if (installCommand.trim()) {
88
- console.log(`Running "install" command: \`${installCommand}\`...`);
89
- await (0, import_build_utils.execCommand)(installCommand, {
90
- ...spawnOpts,
91
- cwd: entrypointFsDirname
92
- });
93
- } else {
94
- console.log(`Skipping "install" command...`);
95
- }
96
- } else {
97
- await (0, import_build_utils.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
98
- }
99
- const isHydrogen2 = pkg.dependencies?.["@shopify/remix-oxygen"] || pkg.devDependencies?.["@shopify/remix-oxygen"];
100
- const remixRunDevPath = await (0, import_utils.ensureResolvable)(
101
- entrypointFsDirname,
102
- repoRootPath,
103
- "@remix-run/dev"
104
- );
105
- const remixRunDevPkg = JSON.parse(
106
- (0, import_fs.readFileSync)((0, import_path.join)(remixRunDevPath, "package.json"), "utf8")
107
- );
108
- const remixVersion = remixRunDevPkg.version;
109
- const remixConfig = await (0, import_utils.chdirAndReadConfig)(
110
- remixRunDevPath,
111
- entrypointFsDirname,
112
- packageJsonPath
113
- );
114
- const { serverEntryPoint, appDirectory } = remixConfig;
115
- const remixRoutes = Object.values(remixConfig.routes);
116
- const depsToAdd = [];
117
- if (!isHydrogen2 && remixRunDevPkg.name !== "@vercel/remix-run-dev") {
118
- const remixDevForkVersion = (0, import_utils.resolveSemverMinMax)(
119
- REMIX_RUN_DEV_MIN_VERSION,
120
- REMIX_RUN_DEV_MAX_VERSION,
121
- remixVersion
122
- );
123
- depsToAdd.push(
124
- `@remix-run/dev@npm:@vercel/remix-run-dev@${remixDevForkVersion}`
125
- );
126
- }
127
- const userEntryServerFile = (0, import_utils.findEntry)(appDirectory, "entry.server");
128
- if (!userEntryServerFile) {
129
- await import_fs.promises.copyFile(
130
- (0, import_path.join)(DEFAULTS_PATH, "entry.server.jsx"),
131
- (0, import_path.join)(appDirectory, "entry.server.jsx")
132
- );
133
- if (!pkg.dependencies["@vercel/remix"]) {
134
- const vercelRemixVersion = (0, import_utils.resolveSemverMinMax)(
135
- VERCEL_REMIX_MIN_VERSION,
136
- REMIX_RUN_DEV_MAX_VERSION,
137
- remixVersion
138
- );
139
- depsToAdd.push(`@vercel/remix@${vercelRemixVersion}`);
140
- }
141
- }
142
- if (depsToAdd.length) {
143
- await (0, import_utils.addDependencies)(cliType, depsToAdd, {
144
- ...spawnOpts,
145
- cwd: entrypointFsDirname
146
- });
147
- }
148
- const userEntryClientFile = (0, import_utils.findEntry)(
149
- remixConfig.appDirectory,
150
- "entry.client"
151
- );
152
- if (!userEntryClientFile) {
153
- await import_fs.promises.copyFile(
154
- (0, import_path.join)(DEFAULTS_PATH, "entry.client.react.jsx"),
155
- (0, import_path.join)(appDirectory, "entry.client.jsx")
156
- );
157
- }
158
- let remixConfigWrapped = false;
159
- let serverEntryPointAbs;
160
- let originalServerEntryPoint;
161
- const remixConfigPath = (0, import_utils.findConfig)(entrypointFsDirname, "remix.config");
162
- const renamedRemixConfigPath = remixConfigPath ? `${remixConfigPath}.original${(0, import_path.extname)(remixConfigPath)}` : void 0;
163
- let serverBundles;
164
- const serverBundlesMap = /* @__PURE__ */ new Map();
165
- const resolvedConfigsMap = /* @__PURE__ */ new Map();
166
- try {
167
- const project = new import_ts_morph.Project();
168
- const staticConfigsMap = /* @__PURE__ */ new Map();
169
- for (const route of remixRoutes) {
170
- const routePath = (0, import_path.join)(remixConfig.appDirectory, route.file);
171
- let staticConfig = (0, import_static_config.getConfig)(project, routePath);
172
- if (staticConfig && isHydrogen2) {
173
- console.log(
174
- "WARN: `export const config` is currently not supported for Hydrogen v2 apps"
175
- );
176
- staticConfig = null;
177
- }
178
- staticConfigsMap.set(route, staticConfig);
179
- }
180
- for (const route of remixRoutes) {
181
- const config2 = (0, import_utils.getResolvedRouteConfig)(
182
- route,
183
- remixConfig.routes,
184
- staticConfigsMap,
185
- isHydrogen2
186
- );
187
- resolvedConfigsMap.set(route, config2);
188
- }
189
- for (const route of remixRoutes) {
190
- if ((0, import_utils.isLayoutRoute)(route.id, remixRoutes))
191
- continue;
192
- const config2 = resolvedConfigsMap.get(route);
193
- if (!config2) {
194
- throw new Error(`Expected resolved config for "${route.id}"`);
195
- }
196
- const hash = (0, import_utils.calculateRouteConfigHash)(config2);
197
- let routesForHash = serverBundlesMap.get(hash);
198
- if (!Array.isArray(routesForHash)) {
199
- routesForHash = [];
200
- serverBundlesMap.set(hash, routesForHash);
201
- }
202
- routesForHash.push(route);
203
- }
204
- serverBundles = Array.from(serverBundlesMap.entries()).map(
205
- ([hash, routes2]) => {
206
- const runtime = resolvedConfigsMap.get(routes2[0])?.runtime ?? "nodejs";
207
- return {
208
- serverBuildPath: isHydrogen2 ? (0, import_path.relative)(entrypointFsDirname, remixConfig.serverBuildPath) : `${(0, import_path.relative)(
209
- entrypointFsDirname,
210
- (0, import_path.dirname)(remixConfig.serverBuildPath)
211
- )}/build-${runtime}-${hash}.js`,
212
- routes: routes2.map((r) => r.id)
213
- };
214
- }
215
- );
216
- if (!isHydrogen2 && remixConfigPath && renamedRemixConfigPath) {
217
- await import_fs.promises.rename(remixConfigPath, renamedRemixConfigPath);
218
- let patchedConfig;
219
- if ((0, import_utils.isESM)(renamedRemixConfigPath)) {
220
- patchedConfig = `import config from './${(0, import_path.basename)(
221
- renamedRemixConfigPath
222
- )}';
223
- config.serverBuildTarget = undefined;
224
- config.serverModuleFormat = 'cjs';
225
- config.serverPlatform = 'node';
226
- config.serverBuildPath = undefined;
227
- config.serverBundles = ${JSON.stringify(serverBundles)};
228
- export default config;`;
229
- } else {
230
- patchedConfig = `const config = require('./${(0, import_path.basename)(
231
- renamedRemixConfigPath
232
- )}');
233
- config.serverBuildTarget = undefined;
234
- config.serverModuleFormat = 'cjs';
235
- config.serverPlatform = 'node';
236
- config.serverBuildPath = undefined;
237
- config.serverBundles = ${JSON.stringify(serverBundles)};
238
- module.exports = config;`;
239
- }
240
- await import_fs.promises.writeFile(remixConfigPath, patchedConfig);
241
- remixConfigWrapped = true;
242
- }
243
- if (isHydrogen2) {
244
- if (remixConfig.serverEntryPoint) {
245
- serverEntryPointAbs = (0, import_path.join)(
246
- entrypointFsDirname,
247
- remixConfig.serverEntryPoint
248
- );
249
- originalServerEntryPoint = await import_fs.promises.readFile(
250
- serverEntryPointAbs,
251
- "utf8"
252
- );
253
- const patchedServerEntryPoint = (0, import_hydrogen.patchHydrogenServer)(
254
- project,
255
- serverEntryPointAbs
256
- );
257
- if (patchedServerEntryPoint) {
258
- (0, import_build_utils.debug)(
259
- `Patched Hydrogen server file: ${remixConfig.serverEntryPoint}`
260
- );
261
- await import_fs.promises.writeFile(serverEntryPointAbs, patchedServerEntryPoint);
262
- }
263
- } else {
264
- console.log('WARN: No "server" field found in Remix config');
265
- }
266
- }
267
- spawnOpts.env.NODE_ENV = "production";
268
- if (buildCommand) {
269
- (0, import_build_utils.debug)(`Executing build command "${buildCommand}"`);
270
- await (0, import_build_utils.execCommand)(buildCommand, {
271
- ...spawnOpts,
272
- cwd: entrypointFsDirname
273
- });
274
- } else {
275
- if (hasScript("vercel-build", pkg)) {
276
- (0, import_build_utils.debug)(`Executing "yarn vercel-build"`);
277
- await (0, import_build_utils.runPackageJsonScript)(
278
- entrypointFsDirname,
279
- "vercel-build",
280
- spawnOpts
281
- );
282
- } else if (hasScript("build", pkg)) {
283
- (0, import_build_utils.debug)(`Executing "yarn build"`);
284
- await (0, import_build_utils.runPackageJsonScript)(entrypointFsDirname, "build", spawnOpts);
285
- } else {
286
- await (0, import_build_utils.execCommand)("remix build", {
287
- ...spawnOpts,
288
- cwd: entrypointFsDirname
289
- });
290
- }
291
- }
292
- } finally {
293
- const cleanupOps = [];
294
- if (remixConfigWrapped && remixConfigPath && renamedRemixConfigPath) {
295
- cleanupOps.push(
296
- import_fs.promises.rename(renamedRemixConfigPath, remixConfigPath).then(
297
- () => (0, import_build_utils.debug)(`Restored original "${(0, import_path.basename)(remixConfigPath)}" file`)
298
- )
299
- );
300
- }
301
- if (serverEntryPointAbs && originalServerEntryPoint) {
302
- cleanupOps.push(
303
- import_fs.promises.writeFile(serverEntryPointAbs, originalServerEntryPoint).then(
304
- () => (0, import_build_utils.debug)(`Restored original "${(0, import_path.basename)(serverEntryPointAbs)}" file`)
305
- )
306
- );
307
- }
308
- await Promise.all(cleanupOps);
309
- }
310
- await Promise.all([
311
- (0, import_utils.ensureResolvable)(
312
- entrypointFsDirname,
313
- repoRootPath,
314
- "@remix-run/server-runtime"
315
- ),
316
- !isHydrogen2 ? (0, import_utils.ensureResolvable)(entrypointFsDirname, repoRootPath, "@remix-run/node") : null
317
- ]);
318
- const staticDir = (0, import_path.join)(
319
- remixConfig.assetsBuildDirectory,
320
- ...remixConfig.publicPath.replace(/^\/|\/$/g, "").split("/").map((_) => "..")
321
- );
322
- const [staticFiles, ...functions] = await Promise.all([
323
- (0, import_build_utils.glob)("**", staticDir),
324
- ...serverBundles.map((bundle) => {
325
- const firstRoute = remixConfig.routes[bundle.routes[0]];
326
- const config2 = resolvedConfigsMap.get(firstRoute) ?? {
327
- runtime: "nodejs"
328
- };
329
- if (config2.runtime === "edge") {
330
- return createRenderEdgeFunction(
331
- entrypointFsDirname,
332
- repoRootPath,
333
- (0, import_path.join)(entrypointFsDirname, bundle.serverBuildPath),
334
- serverEntryPoint,
335
- remixVersion,
336
- config2
337
- );
338
- }
339
- return createRenderNodeFunction(
340
- nodeVersion,
341
- entrypointFsDirname,
342
- repoRootPath,
343
- (0, import_path.join)(entrypointFsDirname, bundle.serverBuildPath),
344
- serverEntryPoint,
345
- remixVersion,
346
- config2
347
- );
348
- })
349
- ]);
350
- const output = staticFiles;
351
- const routes = [
352
- {
353
- src: "^/build/(.*)$",
354
- headers: { "cache-control": "public, max-age=31536000, immutable" },
355
- continue: true
356
- },
357
- {
358
- handle: "filesystem"
359
- }
360
- ];
361
- for (const route of remixRoutes) {
362
- if ((0, import_utils.isLayoutRoute)(route.id, remixRoutes))
363
- continue;
364
- const { path, rePath } = (0, import_utils.getPathFromRoute)(route, remixConfig.routes);
365
- if (!path) {
366
- continue;
367
- }
368
- const funcIndex = serverBundles.findIndex((bundle) => {
369
- return bundle.routes.includes(route.id);
370
- });
371
- const func = functions[funcIndex];
372
- if (!func) {
373
- throw new Error(`Could not determine server bundle for "${route.id}"`);
374
- }
375
- output[path] = func instanceof import_build_utils.EdgeFunction ? (
376
- // `EdgeFunction` currently requires the "name" property to be set.
377
- // Ideally this property will be removed, at which point we can
378
- // return the same `edgeFunction` instance instead of creating a
379
- // new one for each page.
380
- new import_build_utils.EdgeFunction({
381
- ...func,
382
- name: path
383
- })
384
- ) : func;
385
- const re = (0, import_utils.getRegExpFromPath)(rePath);
386
- if (re) {
387
- routes.push({
388
- src: re.source,
389
- dest: path
390
- });
391
- }
392
- }
393
- if (!output["404"]) {
394
- const edgeFunctionIndex = Array.from(serverBundlesMap.values()).findIndex(
395
- (routes2) => {
396
- const runtime = resolvedConfigsMap.get(routes2[0])?.runtime;
397
- return runtime === "edge";
398
- }
399
- );
400
- const func = edgeFunctionIndex !== -1 ? functions[edgeFunctionIndex] : functions[0];
401
- output["404"] = func instanceof import_build_utils.EdgeFunction ? new import_build_utils.EdgeFunction({ ...func, name: "404" }) : func;
402
- }
403
- routes.push({
404
- src: "/(.*)",
405
- dest: "/404"
406
- });
407
- return { routes, output, framework: { version: remixVersion } };
408
- };
409
- function hasScript(scriptName, pkg) {
410
- const scripts = pkg && pkg.scripts || {};
411
- return typeof scripts[scriptName] === "string";
412
- }
413
- async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, serverBuildPath, serverEntryPoint, remixVersion, config) {
414
- const files = {};
415
- let handler = (0, import_path.relative)(rootDir, serverBuildPath);
416
- let handlerPath = (0, import_path.join)(rootDir, handler);
417
- if (!serverEntryPoint) {
418
- const baseServerBuildPath = (0, import_path.basename)(serverBuildPath, ".js");
419
- handler = (0, import_path.join)((0, import_path.dirname)(handler), `server-${baseServerBuildPath}.mjs`);
420
- handlerPath = (0, import_path.join)(rootDir, handler);
421
- const nodeServerSrc = await nodeServerSrcPromise;
422
- await writeEntrypointFile(
423
- handlerPath,
424
- nodeServerSrc.replace(
425
- "@remix-run/dev/server-build",
426
- `./${baseServerBuildPath}.js`
427
- ),
428
- rootDir
429
- );
430
- }
431
- const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
432
- base: rootDir,
433
- processCwd: entrypointDir
434
- });
435
- for (const warning of trace.warnings) {
436
- (0, import_build_utils.debug)(`Warning from trace: ${warning.message}`);
437
- }
438
- for (const file of trace.fileList) {
439
- files[file] = await import_build_utils.FileFsRef.fromFsPath({ fsPath: (0, import_path.join)(rootDir, file) });
440
- }
441
- const fn = new import_build_utils.NodejsLambda({
442
- files,
443
- handler,
444
- runtime: nodeVersion.runtime,
445
- shouldAddHelpers: false,
446
- shouldAddSourcemapSupport: false,
447
- operationType: "SSR",
448
- supportsResponseStreaming: true,
449
- regions: config.regions,
450
- memory: config.memory,
451
- maxDuration: config.maxDuration,
452
- framework: {
453
- slug: "remix",
454
- version: remixVersion
455
- }
456
- });
457
- return fn;
458
- }
459
- async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath, serverEntryPoint, remixVersion, config) {
460
- const files = {};
461
- let handler = (0, import_path.relative)(rootDir, serverBuildPath);
462
- let handlerPath = (0, import_path.join)(rootDir, handler);
463
- if (!serverEntryPoint) {
464
- const baseServerBuildPath = (0, import_path.basename)(serverBuildPath, ".js");
465
- handler = (0, import_path.join)((0, import_path.dirname)(handler), `server-${baseServerBuildPath}.mjs`);
466
- handlerPath = (0, import_path.join)(rootDir, handler);
467
- const edgeServerSrc = await edgeServerSrcPromise;
468
- await writeEntrypointFile(
469
- handlerPath,
470
- edgeServerSrc.replace(
471
- "@remix-run/dev/server-build",
472
- `./${baseServerBuildPath}.js`
473
- ),
474
- rootDir
475
- );
476
- }
477
- let remixRunVercelPkgJson;
478
- const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
479
- base: rootDir,
480
- processCwd: entrypointDir,
481
- conditions: ["edge-light", "browser", "module", "import", "require"],
482
- async readFile(fsPath) {
483
- let source;
484
- try {
485
- source = await import_fs.promises.readFile(fsPath);
486
- } catch (err) {
487
- if (err.code === "ENOENT" || err.code === "EISDIR") {
488
- return null;
489
- }
490
- throw err;
491
- }
492
- if ((0, import_path.basename)(fsPath) === "package.json") {
493
- const pkgJson = JSON.parse(source.toString());
494
- if (pkgJson.name === "@remix-run/vercel") {
495
- pkgJson.browser = "dist/edge.js";
496
- pkgJson.dependencies["@remix-run/server-runtime"] = pkgJson.dependencies["@remix-run/node"];
497
- if (!remixRunVercelPkgJson) {
498
- remixRunVercelPkgJson = JSON.stringify(pkgJson, null, 2) + "\n";
499
- const vercelEdgeEntrypointPath = (0, import_path.join)(
500
- DEFAULTS_PATH,
501
- "vercel-edge-entrypoint.js"
502
- );
503
- const vercelEdgeEntrypointDest = (0, import_path.join)(
504
- (0, import_path.dirname)(fsPath),
505
- "dist/edge.js"
506
- );
507
- await import_fs.promises.copyFile(
508
- vercelEdgeEntrypointPath,
509
- vercelEdgeEntrypointDest
510
- );
511
- }
512
- }
513
- for (const prop of ["browser", "module"]) {
514
- const val = pkgJson[prop];
515
- if (typeof val === "string") {
516
- pkgJson.main = val;
517
- source = JSON.stringify(pkgJson);
518
- break;
519
- }
520
- }
521
- }
522
- return source;
523
- }
524
- });
525
- for (const warning of trace.warnings) {
526
- (0, import_build_utils.debug)(`Warning from trace: ${warning.message}`);
527
- }
528
- for (const file of trace.fileList) {
529
- if (remixRunVercelPkgJson && file.endsWith(`@remix-run${import_path.sep}vercel${import_path.sep}package.json`)) {
530
- files[file] = new import_build_utils.FileBlob({ data: remixRunVercelPkgJson });
531
- } else {
532
- files[file] = await import_build_utils.FileFsRef.fromFsPath({ fsPath: (0, import_path.join)(rootDir, file) });
533
- }
534
- }
535
- const fn = new import_build_utils.EdgeFunction({
536
- files,
537
- deploymentTarget: "v8-worker",
538
- name: "render",
539
- entrypoint: handler,
540
- regions: config.regions,
541
- framework: {
542
- slug: "remix",
543
- version: remixVersion
544
- }
545
- });
546
- return fn;
547
- }
548
- async function writeEntrypointFile(path, data, rootDir) {
549
- try {
550
- await import_fs.promises.writeFile(path, data);
551
- } catch (err) {
552
- if (err.code === "ENOENT") {
553
- throw new Error(
554
- `The "${(0, import_path.relative)(
555
- rootDir,
556
- (0, import_path.dirname)(path)
557
- )}" directory does not exist. Please contact support at https://vercel.com/help.`
558
- );
559
- }
560
- throw err;
561
- }
562
- }
563
- // Annotate the CommonJS export names for ESM import in node:
564
- 0 && (module.exports = {
565
- build
566
- });
567
- //# sourceMappingURL=build.js.map