@vercel/remix-builder 1.6.2
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/defaults/entry.client.react.jsx +22 -0
- package/defaults/entry.server.jsx +17 -0
- package/defaults/server-edge.mjs +3 -0
- package/defaults/server-node.mjs +76 -0
- package/defaults/vercel-edge-entrypoint.js +21 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.js +509 -0
- package/dist/build.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/prepare-cache.d.ts +2 -0
- package/dist/prepare-cache.js +22 -0
- package/dist/prepare-cache.js.map +1 -0
- package/dist/utils.d.ts +50 -0
- package/dist/utils.js +200 -0
- package/dist/utils.js.map +1 -0
- package/package.json +35 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RemixBrowser } from '@remix-run/react';
|
|
2
|
+
import { startTransition, StrictMode } from 'react';
|
|
3
|
+
import { hydrateRoot } from 'react-dom/client';
|
|
4
|
+
|
|
5
|
+
function hydrate() {
|
|
6
|
+
startTransition(() => {
|
|
7
|
+
hydrateRoot(
|
|
8
|
+
document,
|
|
9
|
+
<StrictMode>
|
|
10
|
+
<RemixBrowser />
|
|
11
|
+
</StrictMode>
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (typeof requestIdleCallback === 'function') {
|
|
17
|
+
requestIdleCallback(hydrate);
|
|
18
|
+
} else {
|
|
19
|
+
// Safari doesn't support requestIdleCallback
|
|
20
|
+
// https://caniuse.com/requestidlecallback
|
|
21
|
+
setTimeout(hydrate, 1);
|
|
22
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import handleRequest from '@vercel/remix-entry-server';
|
|
2
|
+
import { RemixServer } from '@remix-run/react';
|
|
3
|
+
|
|
4
|
+
export default function (
|
|
5
|
+
request,
|
|
6
|
+
responseStatusCode,
|
|
7
|
+
responseHeaders,
|
|
8
|
+
remixContext
|
|
9
|
+
) {
|
|
10
|
+
const remixServer = <RemixServer context={remixContext} url={request.url} />;
|
|
11
|
+
return handleRequest(
|
|
12
|
+
request,
|
|
13
|
+
responseStatusCode,
|
|
14
|
+
responseHeaders,
|
|
15
|
+
remixServer
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AbortController as NodeAbortController,
|
|
3
|
+
createRequestHandler as createRemixRequestHandler,
|
|
4
|
+
Headers as NodeHeaders,
|
|
5
|
+
Request as NodeRequest,
|
|
6
|
+
writeReadableStreamToWritable,
|
|
7
|
+
installGlobals,
|
|
8
|
+
} from '@remix-run/node';
|
|
9
|
+
|
|
10
|
+
installGlobals();
|
|
11
|
+
|
|
12
|
+
import build from '@remix-run/dev/server-build';
|
|
13
|
+
|
|
14
|
+
const handleRequest = createRemixRequestHandler(build, process.env.NODE_ENV);
|
|
15
|
+
|
|
16
|
+
function createRemixHeaders(requestHeaders) {
|
|
17
|
+
const headers = new NodeHeaders();
|
|
18
|
+
|
|
19
|
+
for (const key in requestHeaders) {
|
|
20
|
+
const header = requestHeaders[key];
|
|
21
|
+
// set-cookie is an array (maybe others)
|
|
22
|
+
if (Array.isArray(header)) {
|
|
23
|
+
for (const value of header) {
|
|
24
|
+
headers.append(key, value);
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
headers.append(key, header);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return headers;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function createRemixRequest(req, res) {
|
|
35
|
+
const host = req.headers['x-forwarded-host'] || req.headers['host'];
|
|
36
|
+
const protocol = req.headers['x-forwarded-proto'] || 'https';
|
|
37
|
+
const url = new URL(req.url, `${protocol}://${host}`);
|
|
38
|
+
|
|
39
|
+
// Abort action/loaders once we can no longer write a response
|
|
40
|
+
const controller = new NodeAbortController();
|
|
41
|
+
res.on('close', () => controller.abort());
|
|
42
|
+
|
|
43
|
+
const init = {
|
|
44
|
+
method: req.method,
|
|
45
|
+
headers: createRemixHeaders(req.headers),
|
|
46
|
+
signal: controller.signal,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
50
|
+
init.body = req;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return new NodeRequest(url.href, init);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function sendRemixResponse(res, nodeResponse) {
|
|
57
|
+
res.statusMessage = nodeResponse.statusText;
|
|
58
|
+
let multiValueHeaders = nodeResponse.headers.raw();
|
|
59
|
+
res.writeHead(
|
|
60
|
+
nodeResponse.status,
|
|
61
|
+
nodeResponse.statusText,
|
|
62
|
+
multiValueHeaders
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
if (nodeResponse.body) {
|
|
66
|
+
await writeReadableStreamToWritable(nodeResponse.body, res);
|
|
67
|
+
} else {
|
|
68
|
+
res.end();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export default async (req, res) => {
|
|
73
|
+
const request = createRemixRequest(req, res);
|
|
74
|
+
const response = await handleRequest(request);
|
|
75
|
+
await sendRemixResponse(res, response);
|
|
76
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge runtime entrypoint for `@remix-run/vercel`.
|
|
3
|
+
*/
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7
|
+
|
|
8
|
+
var serverRuntime = require('@remix-run/server-runtime');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns a request handler for the Vercel Edge runtime that serves
|
|
12
|
+
* the Remix SSR response.
|
|
13
|
+
*/
|
|
14
|
+
function createRequestHandler({ build, mode }) {
|
|
15
|
+
let handleRequest = serverRuntime.createRequestHandler(build, mode);
|
|
16
|
+
return request => {
|
|
17
|
+
return handleRequest(request);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.createRequestHandler = createRequestHandler;
|
package/dist/build.d.ts
ADDED
package/dist/build.js
ADDED
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const path_1 = require("path");
|
|
7
|
+
const build_utils_1 = require("@vercel/build-utils");
|
|
8
|
+
const static_config_1 = require("@vercel/static-config");
|
|
9
|
+
const nft_1 = require("@vercel/nft");
|
|
10
|
+
const utils_1 = require("./utils");
|
|
11
|
+
const _require = eval('require');
|
|
12
|
+
const REMIX_RUN_DEV_PATH = (0, path_1.dirname)(_require.resolve('@remix-run/dev/package.json'));
|
|
13
|
+
const DEFAULTS_PATH = (0, path_1.join)(__dirname, '../defaults');
|
|
14
|
+
const edgeServerSrcPromise = fs_1.promises.readFile((0, path_1.join)(DEFAULTS_PATH, 'server-edge.mjs'), 'utf-8');
|
|
15
|
+
const nodeServerSrcPromise = fs_1.promises.readFile((0, path_1.join)(DEFAULTS_PATH, 'server-node.mjs'), 'utf-8');
|
|
16
|
+
const build = async ({ entrypoint, files, workPath, repoRootPath, config, meta = {}, }) => {
|
|
17
|
+
const { installCommand, buildCommand } = config;
|
|
18
|
+
await (0, build_utils_1.download)(files, workPath, meta);
|
|
19
|
+
const mountpoint = (0, path_1.dirname)(entrypoint);
|
|
20
|
+
const entrypointFsDirname = (0, path_1.join)(workPath, mountpoint);
|
|
21
|
+
// Run "Install Command"
|
|
22
|
+
const nodeVersion = await (0, build_utils_1.getNodeVersion)(entrypointFsDirname, undefined, config, meta);
|
|
23
|
+
const { cliType, packageJsonPath, lockfileVersion } = await (0, build_utils_1.scanParentDirs)(entrypointFsDirname);
|
|
24
|
+
if (!packageJsonPath) {
|
|
25
|
+
throw new Error('Failed to locate `package.json` file in your project');
|
|
26
|
+
}
|
|
27
|
+
const pkgRaw = await fs_1.promises.readFile(packageJsonPath, 'utf8');
|
|
28
|
+
const pkg = JSON.parse(pkgRaw);
|
|
29
|
+
const spawnOpts = (0, build_utils_1.getSpawnOptions)(meta, nodeVersion);
|
|
30
|
+
if (!spawnOpts.env) {
|
|
31
|
+
spawnOpts.env = {};
|
|
32
|
+
}
|
|
33
|
+
spawnOpts.env = (0, build_utils_1.getEnvForPackageManager)({
|
|
34
|
+
cliType,
|
|
35
|
+
lockfileVersion,
|
|
36
|
+
nodeVersion,
|
|
37
|
+
env: spawnOpts.env,
|
|
38
|
+
});
|
|
39
|
+
if (typeof installCommand === 'string') {
|
|
40
|
+
if (installCommand.trim()) {
|
|
41
|
+
console.log(`Running "install" command: \`${installCommand}\`...`);
|
|
42
|
+
await (0, build_utils_1.execCommand)(installCommand, {
|
|
43
|
+
...spawnOpts,
|
|
44
|
+
cwd: entrypointFsDirname,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
console.log(`Skipping "install" command...`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
await (0, build_utils_1.runNpmInstall)(entrypointFsDirname, [], spawnOpts, meta, nodeVersion);
|
|
53
|
+
}
|
|
54
|
+
// Determine the version of Remix based on the `@remix-run/dev`
|
|
55
|
+
// package version.
|
|
56
|
+
const remixRunDevPath = await ensureResolvable(entrypointFsDirname, repoRootPath, '@remix-run/dev');
|
|
57
|
+
const remixVersion = JSON.parse(await fs_1.promises.readFile((0, path_1.join)(remixRunDevPath, 'package.json'), 'utf8')).version;
|
|
58
|
+
const remixConfig = await (0, utils_1.chdirAndReadConfig)(entrypointFsDirname, packageJsonPath);
|
|
59
|
+
const { serverEntryPoint, appDirectory } = remixConfig;
|
|
60
|
+
const remixRoutes = Object.values(remixConfig.routes);
|
|
61
|
+
// `app/entry.server.tsx` and `app/entry.client.tsx` are optional in Remix,
|
|
62
|
+
// so if either of those files are missing then add our own versions.
|
|
63
|
+
const userEntryServerFile = (0, utils_1.findEntry)(appDirectory, 'entry.server');
|
|
64
|
+
if (!userEntryServerFile) {
|
|
65
|
+
await fs_1.promises.copyFile((0, path_1.join)(DEFAULTS_PATH, 'entry.server.jsx'), (0, path_1.join)(appDirectory, 'entry.server.jsx'));
|
|
66
|
+
if (!pkg.dependencies['@vercel/remix-entry-server']) {
|
|
67
|
+
// Prevent frozen lockfile rejections
|
|
68
|
+
const envForAddDep = { ...spawnOpts.env };
|
|
69
|
+
delete envForAddDep.CI;
|
|
70
|
+
delete envForAddDep.VERCEL;
|
|
71
|
+
delete envForAddDep.NOW_BUILDER;
|
|
72
|
+
await (0, utils_1.addDependency)(cliType, ['@vercel/remix-entry-server'], {
|
|
73
|
+
...spawnOpts,
|
|
74
|
+
env: envForAddDep,
|
|
75
|
+
cwd: entrypointFsDirname,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const userEntryClientFile = (0, utils_1.findEntry)(remixConfig.appDirectory, 'entry.client');
|
|
80
|
+
if (!userEntryClientFile) {
|
|
81
|
+
await fs_1.promises.copyFile((0, path_1.join)(DEFAULTS_PATH, 'entry.client.react.jsx'), (0, path_1.join)(appDirectory, 'entry.client.jsx'));
|
|
82
|
+
}
|
|
83
|
+
let remixConfigWrapped = false;
|
|
84
|
+
const remixConfigPath = (0, utils_1.findConfig)(entrypointFsDirname, 'remix.config');
|
|
85
|
+
const renamedRemixConfigPath = remixConfigPath
|
|
86
|
+
? `${remixConfigPath}.original${(0, path_1.extname)(remixConfigPath)}`
|
|
87
|
+
: undefined;
|
|
88
|
+
const backupRemixRunDevPath = `${remixRunDevPath}.__vercel_backup`;
|
|
89
|
+
await fs_1.promises.rename(remixRunDevPath, backupRemixRunDevPath);
|
|
90
|
+
await fs_1.promises.symlink(REMIX_RUN_DEV_PATH, remixRunDevPath);
|
|
91
|
+
// These get populated inside the try/catch below
|
|
92
|
+
let serverBundles;
|
|
93
|
+
const serverBundlesMap = new Map();
|
|
94
|
+
const resolvedConfigsMap = new Map();
|
|
95
|
+
try {
|
|
96
|
+
// Read the `export const config` (if any) for each route
|
|
97
|
+
const project = new ts_morph_1.Project();
|
|
98
|
+
const staticConfigsMap = new Map();
|
|
99
|
+
for (const route of remixRoutes) {
|
|
100
|
+
const routePath = (0, path_1.join)(remixConfig.appDirectory, route.file);
|
|
101
|
+
const staticConfig = (0, static_config_1.getConfig)(project, routePath);
|
|
102
|
+
staticConfigsMap.set(route, staticConfig);
|
|
103
|
+
}
|
|
104
|
+
for (const route of remixRoutes) {
|
|
105
|
+
const config = (0, utils_1.getResolvedRouteConfig)(route, remixConfig.routes, staticConfigsMap);
|
|
106
|
+
resolvedConfigsMap.set(route, config);
|
|
107
|
+
}
|
|
108
|
+
// Figure out which routes belong to which server bundles
|
|
109
|
+
// based on having common static config properties
|
|
110
|
+
for (const route of remixRoutes) {
|
|
111
|
+
if ((0, utils_1.isLayoutRoute)(route.id, remixRoutes))
|
|
112
|
+
continue;
|
|
113
|
+
const config = resolvedConfigsMap.get(route);
|
|
114
|
+
if (!config) {
|
|
115
|
+
throw new Error(`Expected resolved config for "${route.id}"`);
|
|
116
|
+
}
|
|
117
|
+
const hash = (0, utils_1.calculateRouteConfigHash)(config);
|
|
118
|
+
let routesForHash = serverBundlesMap.get(hash);
|
|
119
|
+
if (!Array.isArray(routesForHash)) {
|
|
120
|
+
routesForHash = [];
|
|
121
|
+
serverBundlesMap.set(hash, routesForHash);
|
|
122
|
+
}
|
|
123
|
+
routesForHash.push(route);
|
|
124
|
+
}
|
|
125
|
+
serverBundles = Array.from(serverBundlesMap.entries()).map(([hash, routes]) => {
|
|
126
|
+
const runtime = resolvedConfigsMap.get(routes[0])?.runtime ?? 'nodejs';
|
|
127
|
+
return {
|
|
128
|
+
serverBuildPath: `build/build-${runtime}-${hash}.js`,
|
|
129
|
+
routes: routes.map(r => r.id),
|
|
130
|
+
};
|
|
131
|
+
});
|
|
132
|
+
// We need to patch the `remix.config.js` file to force some values necessary
|
|
133
|
+
// for a build that works on either Node.js or the Edge runtime
|
|
134
|
+
if (remixConfigPath && renamedRemixConfigPath) {
|
|
135
|
+
await fs_1.promises.rename(remixConfigPath, renamedRemixConfigPath);
|
|
136
|
+
// Figure out if the `remix.config` file is using ESM syntax
|
|
137
|
+
let isESM = false;
|
|
138
|
+
try {
|
|
139
|
+
_require(renamedRemixConfigPath);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
isESM = err.code === 'ERR_REQUIRE_ESM';
|
|
143
|
+
}
|
|
144
|
+
let patchedConfig;
|
|
145
|
+
if (isESM) {
|
|
146
|
+
patchedConfig = `import config from './${(0, path_1.basename)(renamedRemixConfigPath)}';
|
|
147
|
+
config.serverBuildTarget = undefined;
|
|
148
|
+
config.serverModuleFormat = 'cjs';
|
|
149
|
+
config.serverPlatform = 'node';
|
|
150
|
+
config.serverBuildPath = undefined;
|
|
151
|
+
config.serverBundles = ${JSON.stringify(serverBundles)};
|
|
152
|
+
export default config;`;
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
patchedConfig = `const config = require('./${(0, path_1.basename)(renamedRemixConfigPath)}');
|
|
156
|
+
config.serverBuildTarget = undefined;
|
|
157
|
+
config.serverModuleFormat = 'cjs';
|
|
158
|
+
config.serverPlatform = 'node';
|
|
159
|
+
config.serverBuildPath = undefined;
|
|
160
|
+
config.serverBundles = ${JSON.stringify(serverBundles)};
|
|
161
|
+
module.exports = config;`;
|
|
162
|
+
}
|
|
163
|
+
await fs_1.promises.writeFile(remixConfigPath, patchedConfig);
|
|
164
|
+
remixConfigWrapped = true;
|
|
165
|
+
}
|
|
166
|
+
// Make `remix build` output production mode
|
|
167
|
+
spawnOpts.env.NODE_ENV = 'production';
|
|
168
|
+
// Run "Build Command"
|
|
169
|
+
if (buildCommand) {
|
|
170
|
+
(0, build_utils_1.debug)(`Executing build command "${buildCommand}"`);
|
|
171
|
+
await (0, build_utils_1.execCommand)(buildCommand, {
|
|
172
|
+
...spawnOpts,
|
|
173
|
+
cwd: entrypointFsDirname,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
if (hasScript('vercel-build', pkg)) {
|
|
178
|
+
(0, build_utils_1.debug)(`Executing "yarn vercel-build"`);
|
|
179
|
+
await (0, build_utils_1.runPackageJsonScript)(entrypointFsDirname, 'vercel-build', spawnOpts);
|
|
180
|
+
}
|
|
181
|
+
else if (hasScript('build', pkg)) {
|
|
182
|
+
(0, build_utils_1.debug)(`Executing "yarn build"`);
|
|
183
|
+
await (0, build_utils_1.runPackageJsonScript)(entrypointFsDirname, 'build', spawnOpts);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
await (0, build_utils_1.execCommand)('remix build', {
|
|
187
|
+
...spawnOpts,
|
|
188
|
+
cwd: entrypointFsDirname,
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
// Clean up our patched `remix.config.js` to be polite
|
|
195
|
+
if (remixConfigWrapped && remixConfigPath && renamedRemixConfigPath) {
|
|
196
|
+
await fs_1.promises.rename(renamedRemixConfigPath, remixConfigPath);
|
|
197
|
+
}
|
|
198
|
+
// Remove `@remix-run/dev` symlink
|
|
199
|
+
await fs_1.promises.unlink(remixRunDevPath);
|
|
200
|
+
await fs_1.promises.rename(backupRemixRunDevPath, remixRunDevPath);
|
|
201
|
+
}
|
|
202
|
+
// This needs to happen before we run NFT to create the Node/Edge functions
|
|
203
|
+
await Promise.all([
|
|
204
|
+
ensureResolvable(entrypointFsDirname, repoRootPath, '@remix-run/server-runtime'),
|
|
205
|
+
ensureResolvable(entrypointFsDirname, repoRootPath, '@remix-run/node'),
|
|
206
|
+
]);
|
|
207
|
+
const [staticFiles, ...functions] = await Promise.all([
|
|
208
|
+
(0, build_utils_1.glob)('**', (0, path_1.join)(entrypointFsDirname, 'public')),
|
|
209
|
+
...serverBundles.map(bundle => {
|
|
210
|
+
const firstRoute = remixConfig.routes[bundle.routes[0]];
|
|
211
|
+
const config = resolvedConfigsMap.get(firstRoute) ?? {
|
|
212
|
+
runtime: 'nodejs',
|
|
213
|
+
};
|
|
214
|
+
if (config.runtime === 'edge') {
|
|
215
|
+
return createRenderEdgeFunction(entrypointFsDirname, repoRootPath, (0, path_1.join)(entrypointFsDirname, bundle.serverBuildPath), serverEntryPoint, remixVersion, config);
|
|
216
|
+
}
|
|
217
|
+
return createRenderNodeFunction(nodeVersion, entrypointFsDirname, repoRootPath, (0, path_1.join)(entrypointFsDirname, bundle.serverBuildPath), serverEntryPoint, remixVersion, config);
|
|
218
|
+
}),
|
|
219
|
+
]);
|
|
220
|
+
const output = staticFiles;
|
|
221
|
+
const routes = [
|
|
222
|
+
{
|
|
223
|
+
src: '^/build/(.*)$',
|
|
224
|
+
headers: { 'cache-control': 'public, max-age=31536000, immutable' },
|
|
225
|
+
continue: true,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
handle: 'filesystem',
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
for (const route of remixRoutes) {
|
|
232
|
+
// Layout routes don't get a function / route added
|
|
233
|
+
if ((0, utils_1.isLayoutRoute)(route.id, remixRoutes))
|
|
234
|
+
continue;
|
|
235
|
+
const { path, rePath } = (0, utils_1.getPathFromRoute)(route, remixConfig.routes);
|
|
236
|
+
// If the route is a pathless layout route (at the root level)
|
|
237
|
+
// and doesn't have any sub-routes, then a function should not be created.
|
|
238
|
+
if (!path) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const funcIndex = serverBundles.findIndex(bundle => {
|
|
242
|
+
return bundle.routes.includes(route.id);
|
|
243
|
+
});
|
|
244
|
+
const func = functions[funcIndex];
|
|
245
|
+
if (!func) {
|
|
246
|
+
throw new Error(`Could not determine server bundle for "${route.id}"`);
|
|
247
|
+
}
|
|
248
|
+
output[path] =
|
|
249
|
+
func instanceof build_utils_1.EdgeFunction
|
|
250
|
+
? // `EdgeFunction` currently requires the "name" property to be set.
|
|
251
|
+
// Ideally this property will be removed, at which point we can
|
|
252
|
+
// return the same `edgeFunction` instance instead of creating a
|
|
253
|
+
// new one for each page.
|
|
254
|
+
new build_utils_1.EdgeFunction({
|
|
255
|
+
...func,
|
|
256
|
+
name: path,
|
|
257
|
+
})
|
|
258
|
+
: func;
|
|
259
|
+
// If this is a dynamic route then add a Vercel route
|
|
260
|
+
const re = (0, utils_1.getRegExpFromPath)(rePath);
|
|
261
|
+
if (re) {
|
|
262
|
+
routes.push({
|
|
263
|
+
src: re.source,
|
|
264
|
+
dest: path,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
// Add a 404 path for not found pages to be server-side rendered by Remix.
|
|
269
|
+
// Use an edge function bundle if one was generated, otherwise use Node.js.
|
|
270
|
+
if (!output['404']) {
|
|
271
|
+
const edgeFunctionIndex = Array.from(serverBundlesMap.values()).findIndex(routes => {
|
|
272
|
+
const runtime = resolvedConfigsMap.get(routes[0])?.runtime;
|
|
273
|
+
return runtime === 'edge';
|
|
274
|
+
});
|
|
275
|
+
const func = edgeFunctionIndex !== -1 ? functions[edgeFunctionIndex] : functions[0];
|
|
276
|
+
output['404'] =
|
|
277
|
+
func instanceof build_utils_1.EdgeFunction
|
|
278
|
+
? new build_utils_1.EdgeFunction({ ...func, name: '404' })
|
|
279
|
+
: func;
|
|
280
|
+
}
|
|
281
|
+
routes.push({
|
|
282
|
+
src: '/(.*)',
|
|
283
|
+
dest: '/404',
|
|
284
|
+
});
|
|
285
|
+
return { routes, output, framework: { version: remixVersion } };
|
|
286
|
+
};
|
|
287
|
+
exports.build = build;
|
|
288
|
+
function hasScript(scriptName, pkg) {
|
|
289
|
+
const scripts = (pkg && pkg.scripts) || {};
|
|
290
|
+
return typeof scripts[scriptName] === 'string';
|
|
291
|
+
}
|
|
292
|
+
async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, serverBuildPath, serverEntryPoint, remixVersion, config) {
|
|
293
|
+
const files = {};
|
|
294
|
+
let handler = (0, path_1.relative)(rootDir, serverBuildPath);
|
|
295
|
+
let handlerPath = (0, path_1.join)(rootDir, handler);
|
|
296
|
+
if (!serverEntryPoint) {
|
|
297
|
+
const baseServerBuildPath = (0, path_1.basename)(serverBuildPath, '.js');
|
|
298
|
+
handler = (0, path_1.join)((0, path_1.dirname)(handler), `server-${baseServerBuildPath}.mjs`);
|
|
299
|
+
handlerPath = (0, path_1.join)(rootDir, handler);
|
|
300
|
+
// Copy the `server-node.mjs` file into the "build" directory
|
|
301
|
+
const nodeServerSrc = await nodeServerSrcPromise;
|
|
302
|
+
await writeEntrypointFile(handlerPath, nodeServerSrc.replace('@remix-run/dev/server-build', `./${baseServerBuildPath}.js`), rootDir);
|
|
303
|
+
}
|
|
304
|
+
// Trace the handler with `@vercel/nft`
|
|
305
|
+
const trace = await (0, nft_1.nodeFileTrace)([handlerPath], {
|
|
306
|
+
base: rootDir,
|
|
307
|
+
processCwd: entrypointDir,
|
|
308
|
+
});
|
|
309
|
+
for (const warning of trace.warnings) {
|
|
310
|
+
(0, build_utils_1.debug)(`Warning from trace: ${warning.message}`);
|
|
311
|
+
}
|
|
312
|
+
for (const file of trace.fileList) {
|
|
313
|
+
files[file] = await build_utils_1.FileFsRef.fromFsPath({ fsPath: (0, path_1.join)(rootDir, file) });
|
|
314
|
+
}
|
|
315
|
+
const fn = new build_utils_1.NodejsLambda({
|
|
316
|
+
files,
|
|
317
|
+
handler,
|
|
318
|
+
runtime: nodeVersion.runtime,
|
|
319
|
+
shouldAddHelpers: false,
|
|
320
|
+
shouldAddSourcemapSupport: false,
|
|
321
|
+
operationType: 'SSR',
|
|
322
|
+
experimentalResponseStreaming: true,
|
|
323
|
+
regions: config.regions,
|
|
324
|
+
memory: config.memory,
|
|
325
|
+
maxDuration: config.maxDuration,
|
|
326
|
+
framework: {
|
|
327
|
+
slug: 'remix',
|
|
328
|
+
version: remixVersion,
|
|
329
|
+
},
|
|
330
|
+
});
|
|
331
|
+
return fn;
|
|
332
|
+
}
|
|
333
|
+
async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath, serverEntryPoint, remixVersion, config) {
|
|
334
|
+
const files = {};
|
|
335
|
+
let handler = (0, path_1.relative)(rootDir, serverBuildPath);
|
|
336
|
+
let handlerPath = (0, path_1.join)(rootDir, handler);
|
|
337
|
+
if (!serverEntryPoint) {
|
|
338
|
+
const baseServerBuildPath = (0, path_1.basename)(serverBuildPath, '.js');
|
|
339
|
+
handler = (0, path_1.join)((0, path_1.dirname)(handler), `server-${baseServerBuildPath}.mjs`);
|
|
340
|
+
handlerPath = (0, path_1.join)(rootDir, handler);
|
|
341
|
+
// Copy the `server-edge.mjs` file into the "build" directory
|
|
342
|
+
const edgeServerSrc = await edgeServerSrcPromise;
|
|
343
|
+
await writeEntrypointFile(handlerPath, edgeServerSrc.replace('@remix-run/dev/server-build', `./${baseServerBuildPath}.js`), rootDir);
|
|
344
|
+
}
|
|
345
|
+
let remixRunVercelPkgJson;
|
|
346
|
+
// Trace the handler with `@vercel/nft`
|
|
347
|
+
const trace = await (0, nft_1.nodeFileTrace)([handlerPath], {
|
|
348
|
+
base: rootDir,
|
|
349
|
+
processCwd: entrypointDir,
|
|
350
|
+
conditions: ['worker', 'browser'],
|
|
351
|
+
async readFile(fsPath) {
|
|
352
|
+
let source;
|
|
353
|
+
try {
|
|
354
|
+
source = await fs_1.promises.readFile(fsPath);
|
|
355
|
+
}
|
|
356
|
+
catch (err) {
|
|
357
|
+
if (err.code === 'ENOENT' || err.code === 'EISDIR') {
|
|
358
|
+
return null;
|
|
359
|
+
}
|
|
360
|
+
throw err;
|
|
361
|
+
}
|
|
362
|
+
if ((0, path_1.basename)(fsPath) === 'package.json') {
|
|
363
|
+
// For Edge Functions, patch "main" field to prefer "browser" or "module"
|
|
364
|
+
const pkgJson = JSON.parse(source.toString());
|
|
365
|
+
// When `@remix-run/vercel` is detected, we need to modify the `package.json`
|
|
366
|
+
// to include the "browser" field so that the proper Edge entrypoint file
|
|
367
|
+
// is used. This is a temporary stop gap until this PR is merged:
|
|
368
|
+
// https://github.com/remix-run/remix/pull/5537
|
|
369
|
+
if (pkgJson.name === '@remix-run/vercel') {
|
|
370
|
+
pkgJson.browser = 'dist/edge.js';
|
|
371
|
+
pkgJson.dependencies['@remix-run/server-runtime'] =
|
|
372
|
+
pkgJson.dependencies['@remix-run/node'];
|
|
373
|
+
if (!remixRunVercelPkgJson) {
|
|
374
|
+
remixRunVercelPkgJson = JSON.stringify(pkgJson, null, 2) + '\n';
|
|
375
|
+
// Copy in the edge entrypoint so that NFT can properly resolve it
|
|
376
|
+
const vercelEdgeEntrypointPath = (0, path_1.join)(DEFAULTS_PATH, 'vercel-edge-entrypoint.js');
|
|
377
|
+
const vercelEdgeEntrypointDest = (0, path_1.join)((0, path_1.dirname)(fsPath), 'dist/edge.js');
|
|
378
|
+
await fs_1.promises.copyFile(vercelEdgeEntrypointPath, vercelEdgeEntrypointDest);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
for (const prop of ['browser', 'module']) {
|
|
382
|
+
const val = pkgJson[prop];
|
|
383
|
+
if (typeof val === 'string') {
|
|
384
|
+
pkgJson.main = val;
|
|
385
|
+
// Return the modified `package.json` to nft
|
|
386
|
+
source = JSON.stringify(pkgJson);
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return source;
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
for (const warning of trace.warnings) {
|
|
395
|
+
(0, build_utils_1.debug)(`Warning from trace: ${warning.message}`);
|
|
396
|
+
}
|
|
397
|
+
for (const file of trace.fileList) {
|
|
398
|
+
if (remixRunVercelPkgJson &&
|
|
399
|
+
file.endsWith(`@remix-run${path_1.sep}vercel${path_1.sep}package.json`)) {
|
|
400
|
+
// Use the modified `@remix-run/vercel` package.json which contains "browser" field
|
|
401
|
+
files[file] = new build_utils_1.FileBlob({ data: remixRunVercelPkgJson });
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
files[file] = await build_utils_1.FileFsRef.fromFsPath({ fsPath: (0, path_1.join)(rootDir, file) });
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const fn = new build_utils_1.EdgeFunction({
|
|
408
|
+
files,
|
|
409
|
+
deploymentTarget: 'v8-worker',
|
|
410
|
+
name: 'render',
|
|
411
|
+
entrypoint: handler,
|
|
412
|
+
regions: config.regions,
|
|
413
|
+
framework: {
|
|
414
|
+
slug: 'remix',
|
|
415
|
+
version: remixVersion,
|
|
416
|
+
},
|
|
417
|
+
});
|
|
418
|
+
return fn;
|
|
419
|
+
}
|
|
420
|
+
async function ensureResolvable(start, base, pkgName) {
|
|
421
|
+
try {
|
|
422
|
+
const resolvedPkgPath = _require.resolve(`${pkgName}/package.json`, {
|
|
423
|
+
paths: [start],
|
|
424
|
+
});
|
|
425
|
+
const resolvedPath = (0, path_1.dirname)(resolvedPkgPath);
|
|
426
|
+
if (!(0, path_1.relative)(base, resolvedPath).startsWith(`..${path_1.sep}`)) {
|
|
427
|
+
// Resolved path is within the root of the project, so all good
|
|
428
|
+
(0, build_utils_1.debug)(`"${pkgName}" resolved to '${resolvedPath}'`);
|
|
429
|
+
return resolvedPath;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
catch (err) {
|
|
433
|
+
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
434
|
+
throw err;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
// If we got to here then `pkgName` was not resolvable up to the root
|
|
438
|
+
// of the project. Try a couple symlink tricks, otherwise we'll bail.
|
|
439
|
+
// Attempt to find the package in `node_modules/.pnpm` (pnpm)
|
|
440
|
+
const pnpmDir = await (0, build_utils_1.walkParentDirs)({
|
|
441
|
+
base,
|
|
442
|
+
start,
|
|
443
|
+
filename: 'node_modules/.pnpm',
|
|
444
|
+
});
|
|
445
|
+
if (pnpmDir) {
|
|
446
|
+
const prefix = `${pkgName.replace('/', '+')}@`;
|
|
447
|
+
const packages = await fs_1.promises.readdir(pnpmDir);
|
|
448
|
+
const match = packages.find(p => p.startsWith(prefix));
|
|
449
|
+
if (match) {
|
|
450
|
+
const pkgDir = (0, path_1.join)(pnpmDir, match, 'node_modules', pkgName);
|
|
451
|
+
await ensureSymlink(pkgDir, (0, path_1.join)(pnpmDir, '..'), pkgName);
|
|
452
|
+
return pkgDir;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// Attempt to find the package in `node_modules/.store` (npm 9+ linked mode)
|
|
456
|
+
const npmDir = await (0, build_utils_1.walkParentDirs)({
|
|
457
|
+
base,
|
|
458
|
+
start,
|
|
459
|
+
filename: 'node_modules/.store',
|
|
460
|
+
});
|
|
461
|
+
if (npmDir) {
|
|
462
|
+
const prefix = `${(0, path_1.basename)(pkgName)}@`;
|
|
463
|
+
const prefixDir = (0, path_1.join)(npmDir, (0, path_1.dirname)(pkgName));
|
|
464
|
+
const packages = await fs_1.promises.readdir(prefixDir);
|
|
465
|
+
const match = packages.find(p => p.startsWith(prefix));
|
|
466
|
+
if (match) {
|
|
467
|
+
const pkgDir = (0, path_1.join)(prefixDir, match, 'node_modules', pkgName);
|
|
468
|
+
await ensureSymlink(pkgDir, (0, path_1.join)(npmDir, '..'), pkgName);
|
|
469
|
+
return pkgDir;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
throw new Error(`Failed to resolve "${pkgName}". To fix this error, add "${pkgName}" to "dependencies" in your \`package.json\` file.`);
|
|
473
|
+
}
|
|
474
|
+
async function ensureSymlink(target, nodeModulesDir, pkgName) {
|
|
475
|
+
const symlinkPath = (0, path_1.join)(nodeModulesDir, pkgName);
|
|
476
|
+
const symlinkDir = (0, path_1.dirname)(symlinkPath);
|
|
477
|
+
const relativeTarget = (0, path_1.relative)(symlinkDir, target);
|
|
478
|
+
try {
|
|
479
|
+
const existingTarget = await fs_1.promises.readlink(symlinkPath);
|
|
480
|
+
if (existingTarget === relativeTarget) {
|
|
481
|
+
// Symlink is already the expected value, so do nothing
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
// If a symlink already exists then delete it if the target doesn't match
|
|
486
|
+
await fs_1.promises.unlink(symlinkPath);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
catch (err) {
|
|
490
|
+
// Ignore when path does not exist or is not a symlink
|
|
491
|
+
if (err.code !== 'ENOENT' && err.code !== 'EINVAL') {
|
|
492
|
+
throw err;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
await fs_1.promises.symlink(relativeTarget, symlinkPath);
|
|
496
|
+
console.warn(`WARN: Created symlink for "${pkgName}". To silence this warning, add "${pkgName}" to "dependencies" in your \`package.json\` file.`);
|
|
497
|
+
}
|
|
498
|
+
async function writeEntrypointFile(path, data, rootDir) {
|
|
499
|
+
try {
|
|
500
|
+
await fs_1.promises.writeFile(path, data);
|
|
501
|
+
}
|
|
502
|
+
catch (err) {
|
|
503
|
+
if (err.code === 'ENOENT') {
|
|
504
|
+
throw new Error(`The "${(0, path_1.relative)(rootDir, (0, path_1.dirname)(path))}" directory does not exist. Please contact support@vercel.com.`);
|
|
505
|
+
}
|
|
506
|
+
throw err;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,2BAAoC;AACpC,+BAAuE;AACvE,qDAgB6B;AAC7B,yDAAkD;AAClD,qCAA4C;AAW5C,mCAaiB;AAEjB,MAAM,QAAQ,GAAmB,IAAI,CAAC,SAAS,CAAC,CAAC;AAEjD,MAAM,kBAAkB,GAAG,IAAA,cAAO,EAChC,QAAQ,CAAC,OAA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,CAAC;IAClD,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,WAAW,CAAC,CAAC;IACxC,MAAM,cAAc,GAAG,IAAA,eAAQ,EAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEpD,IAAI;QACF,MAAM,cAAc,GAAG,MAAM,aAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACtD,IAAI,cAAc,KAAK,cAAc,EAAE;YACrC,uDAAuD;YACvD,OAAO;SACR;aAAM;YACL,yEAAyE;YACzE,MAAM,aAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;SAC9B;KACF;IAAC,OAAO,GAAQ,EAAE;QACjB,sDAAsD;QACtD,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;YAClD,MAAM,GAAG,CAAC;SACX;KACF;IAED,MAAM,aAAE,CAAC,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,CACV,8BAA8B,OAAO,oCAAoC,OAAO,oDAAoD,CACrI,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,mBAAmB,CAChC,IAAY,EACZ,IAAY,EACZ,OAAe;IAEf,IAAI;QACF,MAAM,aAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KAChC;IAAC,OAAO,GAAQ,EAAE;QACjB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE;YACzB,MAAM,IAAI,KAAK,CACb,QAAQ,IAAA,eAAQ,EACd,OAAO,EACP,IAAA,cAAO,EAAC,IAAI,CAAC,CACd,gEAAgE,CAClE,CAAC;SACH;QACD,MAAM,GAAG,CAAC;KACX;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.version = void 0;
|
|
18
|
+
exports.version = 2;
|
|
19
|
+
__exportStar(require("./build"), exports);
|
|
20
|
+
__exportStar(require("./prepare-cache"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAa,QAAA,OAAO,GAAG,CAAC,CAAC;AACzB,0CAAwB;AACxB,kDAAgC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareCache = void 0;
|
|
4
|
+
const build_utils_1 = require("@vercel/build-utils");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
const prepareCache = async ({ entrypoint, repoRootPath, workPath, }) => {
|
|
8
|
+
const root = repoRootPath || workPath;
|
|
9
|
+
const mountpoint = (0, path_1.dirname)(entrypoint);
|
|
10
|
+
const entrypointFsDirname = (0, path_1.join)(workPath, mountpoint);
|
|
11
|
+
const packageJsonPath = (0, path_1.join)(entrypointFsDirname, 'package.json');
|
|
12
|
+
const remixConfig = await (0, utils_1.chdirAndReadConfig)(entrypointFsDirname, packageJsonPath);
|
|
13
|
+
const [nodeModulesFiles, cacheDirFiles] = await Promise.all([
|
|
14
|
+
// Cache `node_modules`
|
|
15
|
+
(0, build_utils_1.glob)('**/node_modules/**', root),
|
|
16
|
+
// Cache the Remix "cacheDirectory" (typically `.cache`)
|
|
17
|
+
(0, build_utils_1.glob)((0, path_1.relative)(root, (0, path_1.join)(remixConfig.cacheDirectory, '**')), root),
|
|
18
|
+
]);
|
|
19
|
+
return { ...nodeModulesFiles, ...cacheDirFiles };
|
|
20
|
+
};
|
|
21
|
+
exports.prepareCache = prepareCache;
|
|
22
|
+
//# sourceMappingURL=prepare-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-cache.js","sourceRoot":"","sources":["../src/prepare-cache.ts"],"names":[],"mappings":";;;AAAA,qDAA2C;AAC3C,+BAA+C;AAC/C,mCAA6C;AAGtC,MAAM,YAAY,GAAiB,KAAK,EAAE,EAC/C,UAAU,EACV,YAAY,EACZ,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,IAAI,GAAG,YAAY,IAAI,QAAQ,CAAC;IACtC,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,UAAU,CAAC,CAAC;IACvC,MAAM,mBAAmB,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACvD,MAAM,eAAe,GAAG,IAAA,WAAI,EAAC,mBAAmB,EAAE,cAAc,CAAC,CAAC;IAClE,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAkB,EAC1C,mBAAmB,EACnB,eAAe,CAChB,CAAC;IACF,MAAM,CAAC,gBAAgB,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1D,uBAAuB;QACvB,IAAA,kBAAI,EAAC,oBAAoB,EAAE,IAAI,CAAC;QAEhC,wDAAwD;QACxD,IAAA,kBAAI,EAAC,IAAA,eAAQ,EAAC,IAAI,EAAE,IAAA,WAAI,EAAC,WAAW,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;KACnE,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,gBAAgB,EAAE,GAAG,aAAa,EAAE,CAAC;AACnD,CAAC,CAAC;AAtBW,QAAA,YAAY,gBAsBvB"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { ConfigRoute, RouteManifest } from '@remix-run/dev/dist/config/routes';
|
|
3
|
+
import type { RemixConfig } from '@remix-run/dev/dist/config';
|
|
4
|
+
import type { BaseFunctionConfig } from '@vercel/static-config';
|
|
5
|
+
import type { CliType, SpawnOptionsExtended } from '@vercel/build-utils/dist/fs/run-user-scripts';
|
|
6
|
+
export interface ResolvedNodeRouteConfig {
|
|
7
|
+
runtime: 'nodejs';
|
|
8
|
+
regions?: string[];
|
|
9
|
+
maxDuration?: number;
|
|
10
|
+
memory?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ResolvedEdgeRouteConfig {
|
|
13
|
+
runtime: 'edge';
|
|
14
|
+
regions?: BaseFunctionConfig['regions'];
|
|
15
|
+
}
|
|
16
|
+
export type ResolvedRouteConfig = ResolvedNodeRouteConfig | ResolvedEdgeRouteConfig;
|
|
17
|
+
export interface ResolvedRoutePaths {
|
|
18
|
+
/**
|
|
19
|
+
* The full URL path of the route, as will be shown
|
|
20
|
+
* on the Functions tab in the deployment inspector.
|
|
21
|
+
*/
|
|
22
|
+
path: string;
|
|
23
|
+
/**
|
|
24
|
+
* The full URL path of the route, but with syntax that
|
|
25
|
+
* is compatible with the `path-to-regexp` module.
|
|
26
|
+
*/
|
|
27
|
+
rePath: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function findEntry(dir: string, basename: string): string | undefined;
|
|
30
|
+
export declare function findConfig(dir: string, basename: string): string | undefined;
|
|
31
|
+
export declare function getResolvedRouteConfig(route: ConfigRoute, routes: RouteManifest, configs: Map<ConfigRoute, BaseFunctionConfig | null>): ResolvedRouteConfig;
|
|
32
|
+
export declare function calculateRouteConfigHash(config: ResolvedRouteConfig): string;
|
|
33
|
+
export declare function isLayoutRoute(routeId: string, routes: Pick<ConfigRoute, 'id' | 'parentId'>[]): boolean;
|
|
34
|
+
export declare function getRouteIterator(route: ConfigRoute, routes: RouteManifest): Generator<ConfigRoute, void, unknown>;
|
|
35
|
+
export declare function getPathFromRoute(route: ConfigRoute, routes: RouteManifest): ResolvedRoutePaths;
|
|
36
|
+
export declare function getRegExpFromPath(rePath: string): RegExp | false;
|
|
37
|
+
/**
|
|
38
|
+
* Updates the `dest` process.env object to match the `source` one.
|
|
39
|
+
* A function is returned to restore the the `dest` env back to how
|
|
40
|
+
* it was originally.
|
|
41
|
+
*/
|
|
42
|
+
export declare function syncEnv(source: NodeJS.ProcessEnv, dest: NodeJS.ProcessEnv): () => any;
|
|
43
|
+
export declare function chdirAndReadConfig(dir: string, packageJsonPath: string): Promise<RemixConfig>;
|
|
44
|
+
export interface AddDependencyOptions extends SpawnOptionsExtended {
|
|
45
|
+
saveDev?: boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Runs `npm i ${name}` / `pnpm i ${name}` / `yarn add ${name}`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function addDependency(cliType: CliType, names: string[], opts?: AddDependencyOptions): Promise<void>;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addDependency = exports.chdirAndReadConfig = exports.syncEnv = exports.getRegExpFromPath = exports.getPathFromRoute = exports.getRouteIterator = exports.isLayoutRoute = exports.calculateRouteConfigHash = exports.getResolvedRouteConfig = exports.findConfig = exports.findEntry = void 0;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const path_to_regexp_1 = require("path-to-regexp");
|
|
7
|
+
const build_utils_1 = require("@vercel/build-utils");
|
|
8
|
+
const config_1 = require("@remix-run/dev/dist/config");
|
|
9
|
+
const SPLAT_PATH = '/:params+';
|
|
10
|
+
const entryExts = ['.js', '.jsx', '.ts', '.tsx'];
|
|
11
|
+
function findEntry(dir, basename) {
|
|
12
|
+
for (const ext of entryExts) {
|
|
13
|
+
const file = (0, path_1.resolve)(dir, basename + ext);
|
|
14
|
+
if ((0, fs_1.existsSync)(file))
|
|
15
|
+
return (0, path_1.relative)(dir, file);
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
exports.findEntry = findEntry;
|
|
20
|
+
const configExts = ['.js', '.cjs', '.mjs'];
|
|
21
|
+
function findConfig(dir, basename) {
|
|
22
|
+
for (const ext of configExts) {
|
|
23
|
+
const name = basename + ext;
|
|
24
|
+
const file = (0, path_1.join)(dir, name);
|
|
25
|
+
if ((0, fs_1.existsSync)(file))
|
|
26
|
+
return file;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
exports.findConfig = findConfig;
|
|
31
|
+
function isEdgeRuntime(runtime) {
|
|
32
|
+
return runtime === 'edge' || runtime === 'experimental-edge';
|
|
33
|
+
}
|
|
34
|
+
function getResolvedRouteConfig(route, routes, configs) {
|
|
35
|
+
let runtime;
|
|
36
|
+
let regions;
|
|
37
|
+
let maxDuration;
|
|
38
|
+
let memory;
|
|
39
|
+
for (const currentRoute of getRouteIterator(route, routes)) {
|
|
40
|
+
const staticConfig = configs.get(currentRoute);
|
|
41
|
+
if (staticConfig) {
|
|
42
|
+
if (typeof runtime === 'undefined' && staticConfig.runtime) {
|
|
43
|
+
runtime = isEdgeRuntime(staticConfig.runtime) ? 'edge' : 'nodejs';
|
|
44
|
+
}
|
|
45
|
+
if (typeof regions === 'undefined') {
|
|
46
|
+
regions = staticConfig.regions;
|
|
47
|
+
}
|
|
48
|
+
if (typeof maxDuration === 'undefined') {
|
|
49
|
+
maxDuration = staticConfig.maxDuration;
|
|
50
|
+
}
|
|
51
|
+
if (typeof memory === 'undefined') {
|
|
52
|
+
memory = staticConfig.memory;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (Array.isArray(regions)) {
|
|
57
|
+
regions = Array.from(new Set(regions)).sort();
|
|
58
|
+
}
|
|
59
|
+
if (runtime === 'edge') {
|
|
60
|
+
return { runtime, regions };
|
|
61
|
+
}
|
|
62
|
+
if (regions && !Array.isArray(regions)) {
|
|
63
|
+
throw new Error(`"regions" for route "${route.id}" must be an array of strings`);
|
|
64
|
+
}
|
|
65
|
+
return { runtime: 'nodejs', regions, maxDuration, memory };
|
|
66
|
+
}
|
|
67
|
+
exports.getResolvedRouteConfig = getResolvedRouteConfig;
|
|
68
|
+
function calculateRouteConfigHash(config) {
|
|
69
|
+
const str = JSON.stringify(config);
|
|
70
|
+
return Buffer.from(str).toString('base64url');
|
|
71
|
+
}
|
|
72
|
+
exports.calculateRouteConfigHash = calculateRouteConfigHash;
|
|
73
|
+
function isLayoutRoute(routeId, routes) {
|
|
74
|
+
return routes.some(r => r.parentId === routeId);
|
|
75
|
+
}
|
|
76
|
+
exports.isLayoutRoute = isLayoutRoute;
|
|
77
|
+
function* getRouteIterator(route, routes) {
|
|
78
|
+
let currentRoute = route;
|
|
79
|
+
do {
|
|
80
|
+
yield currentRoute;
|
|
81
|
+
if (currentRoute.parentId) {
|
|
82
|
+
currentRoute = routes[currentRoute.parentId];
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
} while (currentRoute);
|
|
88
|
+
}
|
|
89
|
+
exports.getRouteIterator = getRouteIterator;
|
|
90
|
+
function getPathFromRoute(route, routes) {
|
|
91
|
+
if (route.id === 'root' ||
|
|
92
|
+
(route.parentId === 'root' && !route.path && route.index)) {
|
|
93
|
+
return { path: 'index', rePath: '/index' };
|
|
94
|
+
}
|
|
95
|
+
const pathParts = [];
|
|
96
|
+
const rePathParts = [];
|
|
97
|
+
for (const currentRoute of getRouteIterator(route, routes)) {
|
|
98
|
+
if (!currentRoute.path)
|
|
99
|
+
continue;
|
|
100
|
+
const currentRouteParts = currentRoute.path.split('/').reverse();
|
|
101
|
+
for (const part of currentRouteParts) {
|
|
102
|
+
if (part.endsWith('?')) {
|
|
103
|
+
if (part.startsWith(':')) {
|
|
104
|
+
// Optional path parameter
|
|
105
|
+
pathParts.push(`(${part.substring(0, part.length - 1)})`);
|
|
106
|
+
rePathParts.push(part);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
// Optional static segment
|
|
110
|
+
const p = `(${part.substring(0, part.length - 1)})`;
|
|
111
|
+
pathParts.push(p);
|
|
112
|
+
rePathParts.push(`${p}?`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
pathParts.push(part);
|
|
117
|
+
rePathParts.push(part);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const path = pathParts.reverse().join('/');
|
|
122
|
+
// Replace "/*" at the end to handle "splat routes"
|
|
123
|
+
let rePath = rePathParts.reverse().join('/');
|
|
124
|
+
rePath =
|
|
125
|
+
rePath === '*' ? SPLAT_PATH : `/${rePath.replace(/\/\*$/, SPLAT_PATH)}`;
|
|
126
|
+
return { path, rePath };
|
|
127
|
+
}
|
|
128
|
+
exports.getPathFromRoute = getPathFromRoute;
|
|
129
|
+
function getRegExpFromPath(rePath) {
|
|
130
|
+
const keys = [];
|
|
131
|
+
const re = (0, path_to_regexp_1.pathToRegexp)(rePath, keys);
|
|
132
|
+
return keys.length > 0 ? re : false;
|
|
133
|
+
}
|
|
134
|
+
exports.getRegExpFromPath = getRegExpFromPath;
|
|
135
|
+
/**
|
|
136
|
+
* Updates the `dest` process.env object to match the `source` one.
|
|
137
|
+
* A function is returned to restore the the `dest` env back to how
|
|
138
|
+
* it was originally.
|
|
139
|
+
*/
|
|
140
|
+
function syncEnv(source, dest) {
|
|
141
|
+
const originalDest = { ...dest };
|
|
142
|
+
Object.assign(dest, source);
|
|
143
|
+
for (const key of Object.keys(dest)) {
|
|
144
|
+
if (!(key in source)) {
|
|
145
|
+
delete dest[key];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return () => syncEnv(originalDest, dest);
|
|
149
|
+
}
|
|
150
|
+
exports.syncEnv = syncEnv;
|
|
151
|
+
async function chdirAndReadConfig(dir, packageJsonPath) {
|
|
152
|
+
const originalCwd = process.cwd();
|
|
153
|
+
// As of Remix v1.14.0, reading the config may trigger adding
|
|
154
|
+
// "isbot" as a dependency, and `npm`/`pnpm`/`yarn` may be invoked.
|
|
155
|
+
// We want to prevent that behavior, so trick `readConfig()`
|
|
156
|
+
// into thinking that "isbot" is already installed.
|
|
157
|
+
let modifiedPackageJson = false;
|
|
158
|
+
const pkgRaw = await fs_1.promises.readFile(packageJsonPath, 'utf8');
|
|
159
|
+
const pkg = JSON.parse(pkgRaw);
|
|
160
|
+
if (!pkg.dependencies?.['isbot']) {
|
|
161
|
+
pkg.dependencies.isbot = 'latest';
|
|
162
|
+
await fs_1.promises.writeFile(packageJsonPath, JSON.stringify(pkg));
|
|
163
|
+
modifiedPackageJson = true;
|
|
164
|
+
}
|
|
165
|
+
let remixConfig;
|
|
166
|
+
try {
|
|
167
|
+
process.chdir(dir);
|
|
168
|
+
remixConfig = await (0, config_1.readConfig)(dir);
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
process.chdir(originalCwd);
|
|
172
|
+
if (modifiedPackageJson) {
|
|
173
|
+
await fs_1.promises.writeFile(packageJsonPath, pkgRaw);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return remixConfig;
|
|
177
|
+
}
|
|
178
|
+
exports.chdirAndReadConfig = chdirAndReadConfig;
|
|
179
|
+
/**
|
|
180
|
+
* Runs `npm i ${name}` / `pnpm i ${name}` / `yarn add ${name}`.
|
|
181
|
+
*/
|
|
182
|
+
function addDependency(cliType, names, opts = {}) {
|
|
183
|
+
const args = [];
|
|
184
|
+
if (cliType === 'npm' || cliType === 'pnpm') {
|
|
185
|
+
args.push('install');
|
|
186
|
+
if (opts.saveDev) {
|
|
187
|
+
args.push('--save-dev');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// 'yarn'
|
|
192
|
+
args.push('add');
|
|
193
|
+
if (opts.saveDev) {
|
|
194
|
+
args.push('--dev');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return (0, build_utils_1.spawnAsync)(cliType, args.concat(names), opts);
|
|
198
|
+
}
|
|
199
|
+
exports.addDependency = addDependency;
|
|
200
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAAA,2BAAgD;AAChD,+BAA+C;AAC/C,mDAAmD;AACnD,qDAAiD;AACjD,uDAAwD;AAwCxD,MAAM,UAAU,GAAG,WAAW,CAAC;AAE/B,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAEjD,SAAgB,SAAS,CAAC,GAAW,EAAE,QAAgB;IACrD,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE;QAC3B,MAAM,IAAI,GAAG,IAAA,cAAO,EAAC,GAAG,EAAE,QAAQ,GAAG,GAAG,CAAC,CAAC;QAC1C,IAAI,IAAA,eAAU,EAAC,IAAI,CAAC;YAAE,OAAO,IAAA,eAAQ,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KAClD;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAPD,8BAOC;AAED,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3C,SAAgB,U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SAAM;QACL,SAAS;QACT,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjB,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACpB;KACF;IACD,OAAO,IAAA,wBAAU,EAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;AACvD,CAAC;AAnBD,sCAmBC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vercel/remix-builder",
|
|
3
|
+
"version": "1.6.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"homepage": "https://vercel.com/docs",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/vercel/vercel.git",
|
|
10
|
+
"directory": "packages/remix"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "node build.js",
|
|
14
|
+
"test": "jest --env node --verbose --bail --runInBand",
|
|
15
|
+
"test-unit": "pnpm test test/unit.*test.*",
|
|
16
|
+
"test-e2e": "pnpm test test/integration.test.ts"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"defaults"
|
|
21
|
+
],
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@remix-run/dev": "npm:@vercel/remix-run-dev@1.14.0",
|
|
24
|
+
"@vercel/build-utils": "6.3.4",
|
|
25
|
+
"@vercel/nft": "0.22.5",
|
|
26
|
+
"@vercel/static-config": "2.0.13",
|
|
27
|
+
"path-to-regexp": "6.2.1",
|
|
28
|
+
"ts-morph": "12.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/jest": "27.5.1",
|
|
32
|
+
"@types/node": "14.18.33",
|
|
33
|
+
"typescript": "4.9.4"
|
|
34
|
+
}
|
|
35
|
+
}
|