@vercel/build-utils 2.12.3-canary.23 → 2.12.3-canary.27
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/convert-runtime-to-plugin.d.ts +4 -13
- package/dist/convert-runtime-to-plugin.js +8 -22
- package/dist/index.js +11 -25
- package/dist/types.d.ts +1 -0
- package/package.json +3 -3
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Lambda } from './lambda';
|
2
|
-
import type {
|
2
|
+
import type { BuildOptions } from './types';
|
3
3
|
/**
|
4
4
|
* Convert legacy Runtime to a Plugin.
|
5
5
|
* @param buildRuntime - a legacy build() function from a Runtime
|
@@ -7,23 +7,14 @@ import type { BuilderFunctions, BuildOptions } from './types';
|
|
7
7
|
*/
|
8
8
|
export declare function convertRuntimeToPlugin(buildRuntime: (options: BuildOptions) => Promise<{
|
9
9
|
output: Lambda;
|
10
|
-
}>, ext: string): ({
|
11
|
-
vercelConfig: {
|
12
|
-
functions?: BuilderFunctions;
|
13
|
-
regions?: string[];
|
14
|
-
};
|
10
|
+
}>, ext: string): ({ workPath }: {
|
15
11
|
workPath: string;
|
16
12
|
}) => Promise<void>;
|
17
13
|
/**
|
18
14
|
* If `.output/functions-manifest.json` exists, append to the pages
|
19
|
-
* property. Otherwise write a new file.
|
20
|
-
* and apply relevant `functions` property config.
|
15
|
+
* property. Otherwise write a new file.
|
21
16
|
*/
|
22
|
-
export declare function updateFunctionsManifest({
|
23
|
-
vercelConfig: {
|
24
|
-
functions?: BuilderFunctions;
|
25
|
-
regions?: string[];
|
26
|
-
};
|
17
|
+
export declare function updateFunctionsManifest({ workPath, pages, }: {
|
27
18
|
workPath: string;
|
28
19
|
pages: {
|
29
20
|
[key: string]: any;
|
@@ -9,7 +9,6 @@ const path_1 = require("path");
|
|
9
9
|
const glob_1 = __importDefault(require("./fs/glob"));
|
10
10
|
const normalize_path_1 = require("./fs/normalize-path");
|
11
11
|
const lambda_1 = require("./lambda");
|
12
|
-
const minimatch_1 = __importDefault(require("minimatch"));
|
13
12
|
/**
|
14
13
|
* Convert legacy Runtime to a Plugin.
|
15
14
|
* @param buildRuntime - a legacy build() function from a Runtime
|
@@ -17,26 +16,24 @@ const minimatch_1 = __importDefault(require("minimatch"));
|
|
17
16
|
*/
|
18
17
|
function convertRuntimeToPlugin(buildRuntime, ext) {
|
19
18
|
// This `build()` signature should match `plugin.build()` signature in `vercel build`.
|
20
|
-
return async function build({
|
19
|
+
return async function build({ workPath }) {
|
21
20
|
const opts = { cwd: workPath };
|
22
21
|
const files = await glob_1.default('**', opts);
|
23
22
|
delete files['vercel.json']; // Builders/Runtimes didn't have vercel.json
|
24
23
|
const entrypoints = await glob_1.default(`api/**/*${ext}`, opts);
|
25
24
|
const pages = {};
|
26
|
-
const { functions = {} } = vercelConfig;
|
27
25
|
const traceDir = path_1.join(workPath, '.output', 'runtime-traced-files');
|
28
26
|
await fs_extra_1.default.ensureDir(traceDir);
|
29
27
|
for (const entrypoint of Object.keys(entrypoints)) {
|
30
|
-
const key = Object.keys(functions).find(src => src === entrypoint || minimatch_1.default(entrypoint, src)) || '';
|
31
|
-
const config = functions[key] || {};
|
32
28
|
const { output } = await buildRuntime({
|
33
29
|
files,
|
34
30
|
entrypoint,
|
35
31
|
workPath,
|
36
32
|
config: {
|
37
33
|
zeroConfig: true,
|
38
|
-
|
39
|
-
|
34
|
+
},
|
35
|
+
meta: {
|
36
|
+
avoidTopLevelInstall: true,
|
40
37
|
},
|
41
38
|
});
|
42
39
|
pages[entrypoint] = {
|
@@ -46,7 +43,6 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
|
|
46
43
|
maxDuration: output.maxDuration,
|
47
44
|
environment: output.environment,
|
48
45
|
allowQuery: output.allowQuery,
|
49
|
-
//regions: output.regions,
|
50
46
|
};
|
51
47
|
// @ts-ignore This symbol is a private API
|
52
48
|
const lambdaFiles = output[lambda_1.FILES_SYMBOL];
|
@@ -79,7 +75,7 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
|
|
79
75
|
await fs_extra_1.default.ensureDir(path_1.dirname(nft));
|
80
76
|
await fs_extra_1.default.writeFile(nft, json);
|
81
77
|
}
|
82
|
-
await updateFunctionsManifest({
|
78
|
+
await updateFunctionsManifest({ workPath, pages });
|
83
79
|
};
|
84
80
|
}
|
85
81
|
exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
|
@@ -107,10 +103,9 @@ async function readJson(filePath) {
|
|
107
103
|
}
|
108
104
|
/**
|
109
105
|
* If `.output/functions-manifest.json` exists, append to the pages
|
110
|
-
* property. Otherwise write a new file.
|
111
|
-
* and apply relevant `functions` property config.
|
106
|
+
* property. Otherwise write a new file.
|
112
107
|
*/
|
113
|
-
async function updateFunctionsManifest({
|
108
|
+
async function updateFunctionsManifest({ workPath, pages, }) {
|
114
109
|
const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
|
115
110
|
const functionsManifest = await readJson(functionsManifestPath);
|
116
111
|
if (!functionsManifest.version)
|
@@ -118,16 +113,7 @@ async function updateFunctionsManifest({ vercelConfig, workPath, pages, }) {
|
|
118
113
|
if (!functionsManifest.pages)
|
119
114
|
functionsManifest.pages = {};
|
120
115
|
for (const [pageKey, pageConfig] of Object.entries(pages)) {
|
121
|
-
|
122
|
-
sourceFile: pageKey,
|
123
|
-
config: vercelConfig,
|
124
|
-
});
|
125
|
-
functionsManifest.pages[pageKey] = {
|
126
|
-
...pageConfig,
|
127
|
-
memory: fnConfig.memory || pageConfig.memory,
|
128
|
-
maxDuration: fnConfig.maxDuration || pageConfig.maxDuration,
|
129
|
-
regions: vercelConfig.regions || pageConfig.regions,
|
130
|
-
};
|
116
|
+
functionsManifest.pages[pageKey] = { ...pageConfig };
|
131
117
|
}
|
132
118
|
await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
|
133
119
|
}
|
package/dist/index.js
CHANGED
@@ -26274,7 +26274,7 @@ exports.frameworks = [
|
|
26274
26274
|
name: 'Remix',
|
26275
26275
|
slug: 'remix',
|
26276
26276
|
demo: 'https://remix.examples.vercel.com',
|
26277
|
-
logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/remix.svg',
|
26277
|
+
logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/remix-no-shadow.svg',
|
26278
26278
|
tagline: 'Build Better Websites',
|
26279
26279
|
description: 'A new Remix app — the result of running `npx create-remix`.',
|
26280
26280
|
website: 'https://remix.run',
|
@@ -26329,8 +26329,8 @@ exports.frameworks = [
|
|
26329
26329
|
],
|
26330
26330
|
defaultHeaders: [
|
26331
26331
|
{
|
26332
|
-
source: '
|
26333
|
-
regex: '
|
26332
|
+
source: '/build/(.*)',
|
26333
|
+
regex: '/build/(.*)',
|
26334
26334
|
headers: [
|
26335
26335
|
{ key: 'cache-control', value: 'public, max-age=31536000, immutable' },
|
26336
26336
|
],
|
@@ -32286,7 +32286,6 @@ const path_1 = __webpack_require__(5622);
|
|
32286
32286
|
const glob_1 = __importDefault(__webpack_require__(4240));
|
32287
32287
|
const normalize_path_1 = __webpack_require__(6261);
|
32288
32288
|
const lambda_1 = __webpack_require__(6721);
|
32289
|
-
const minimatch_1 = __importDefault(__webpack_require__(9566));
|
32290
32289
|
/**
|
32291
32290
|
* Convert legacy Runtime to a Plugin.
|
32292
32291
|
* @param buildRuntime - a legacy build() function from a Runtime
|
@@ -32294,26 +32293,24 @@ const minimatch_1 = __importDefault(__webpack_require__(9566));
|
|
32294
32293
|
*/
|
32295
32294
|
function convertRuntimeToPlugin(buildRuntime, ext) {
|
32296
32295
|
// This `build()` signature should match `plugin.build()` signature in `vercel build`.
|
32297
|
-
return async function build({
|
32296
|
+
return async function build({ workPath }) {
|
32298
32297
|
const opts = { cwd: workPath };
|
32299
32298
|
const files = await glob_1.default('**', opts);
|
32300
32299
|
delete files['vercel.json']; // Builders/Runtimes didn't have vercel.json
|
32301
32300
|
const entrypoints = await glob_1.default(`api/**/*${ext}`, opts);
|
32302
32301
|
const pages = {};
|
32303
|
-
const { functions = {} } = vercelConfig;
|
32304
32302
|
const traceDir = path_1.join(workPath, '.output', 'runtime-traced-files');
|
32305
32303
|
await fs_extra_1.default.ensureDir(traceDir);
|
32306
32304
|
for (const entrypoint of Object.keys(entrypoints)) {
|
32307
|
-
const key = Object.keys(functions).find(src => src === entrypoint || minimatch_1.default(entrypoint, src)) || '';
|
32308
|
-
const config = functions[key] || {};
|
32309
32305
|
const { output } = await buildRuntime({
|
32310
32306
|
files,
|
32311
32307
|
entrypoint,
|
32312
32308
|
workPath,
|
32313
32309
|
config: {
|
32314
32310
|
zeroConfig: true,
|
32315
|
-
|
32316
|
-
|
32311
|
+
},
|
32312
|
+
meta: {
|
32313
|
+
avoidTopLevelInstall: true,
|
32317
32314
|
},
|
32318
32315
|
});
|
32319
32316
|
pages[entrypoint] = {
|
@@ -32323,7 +32320,6 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
|
|
32323
32320
|
maxDuration: output.maxDuration,
|
32324
32321
|
environment: output.environment,
|
32325
32322
|
allowQuery: output.allowQuery,
|
32326
|
-
//regions: output.regions,
|
32327
32323
|
};
|
32328
32324
|
// @ts-ignore This symbol is a private API
|
32329
32325
|
const lambdaFiles = output[lambda_1.FILES_SYMBOL];
|
@@ -32356,7 +32352,7 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
|
|
32356
32352
|
await fs_extra_1.default.ensureDir(path_1.dirname(nft));
|
32357
32353
|
await fs_extra_1.default.writeFile(nft, json);
|
32358
32354
|
}
|
32359
|
-
await updateFunctionsManifest({
|
32355
|
+
await updateFunctionsManifest({ workPath, pages });
|
32360
32356
|
};
|
32361
32357
|
}
|
32362
32358
|
exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
|
@@ -32384,10 +32380,9 @@ async function readJson(filePath) {
|
|
32384
32380
|
}
|
32385
32381
|
/**
|
32386
32382
|
* If `.output/functions-manifest.json` exists, append to the pages
|
32387
|
-
* property. Otherwise write a new file.
|
32388
|
-
* and apply relevant `functions` property config.
|
32383
|
+
* property. Otherwise write a new file.
|
32389
32384
|
*/
|
32390
|
-
async function updateFunctionsManifest({
|
32385
|
+
async function updateFunctionsManifest({ workPath, pages, }) {
|
32391
32386
|
const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
|
32392
32387
|
const functionsManifest = await readJson(functionsManifestPath);
|
32393
32388
|
if (!functionsManifest.version)
|
@@ -32395,16 +32390,7 @@ async function updateFunctionsManifest({ vercelConfig, workPath, pages, }) {
|
|
32395
32390
|
if (!functionsManifest.pages)
|
32396
32391
|
functionsManifest.pages = {};
|
32397
32392
|
for (const [pageKey, pageConfig] of Object.entries(pages)) {
|
32398
|
-
|
32399
|
-
sourceFile: pageKey,
|
32400
|
-
config: vercelConfig,
|
32401
|
-
});
|
32402
|
-
functionsManifest.pages[pageKey] = {
|
32403
|
-
...pageConfig,
|
32404
|
-
memory: fnConfig.memory || pageConfig.memory,
|
32405
|
-
maxDuration: fnConfig.maxDuration || pageConfig.maxDuration,
|
32406
|
-
regions: vercelConfig.regions || pageConfig.regions,
|
32407
|
-
};
|
32393
|
+
functionsManifest.pages[pageKey] = { ...pageConfig };
|
32408
32394
|
}
|
32409
32395
|
await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
|
32410
32396
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "2.12.3-canary.
|
3
|
+
"version": "2.12.3-canary.27",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.js",
|
@@ -30,7 +30,7 @@
|
|
30
30
|
"@types/node-fetch": "^2.1.6",
|
31
31
|
"@types/semver": "6.0.0",
|
32
32
|
"@types/yazl": "^2.4.1",
|
33
|
-
"@vercel/frameworks": "0.5.1-canary.
|
33
|
+
"@vercel/frameworks": "0.5.1-canary.16",
|
34
34
|
"@vercel/ncc": "0.24.0",
|
35
35
|
"aggregate-error": "3.0.1",
|
36
36
|
"async-retry": "1.2.3",
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"typescript": "4.3.4",
|
50
50
|
"yazl": "2.4.3"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "5499fa9a042ef4f44cd4a48f2a168bf5c6d164f5"
|
53
53
|
}
|