@vercel/build-utils 2.12.3-canary.26 → 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.
@@ -1,5 +1,5 @@
1
1
  import { Lambda } from './lambda';
2
- import type { BuilderFunctions, BuildOptions } from './types';
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): ({ vercelConfig, workPath, }: {
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. This will also read `vercel.json`
20
- * and apply relevant `functions` property config.
15
+ * property. Otherwise write a new file.
21
16
  */
22
- export declare function updateFunctionsManifest({ vercelConfig, workPath, pages, }: {
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,21 @@ 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({ vercelConfig, workPath, }) {
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
- includeFiles: config.includeFiles,
39
- excludeFiles: config.excludeFiles,
40
34
  },
41
35
  meta: {
42
36
  avoidTopLevelInstall: true,
@@ -49,7 +43,6 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
49
43
  maxDuration: output.maxDuration,
50
44
  environment: output.environment,
51
45
  allowQuery: output.allowQuery,
52
- //regions: output.regions,
53
46
  };
54
47
  // @ts-ignore This symbol is a private API
55
48
  const lambdaFiles = output[lambda_1.FILES_SYMBOL];
@@ -82,7 +75,7 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
82
75
  await fs_extra_1.default.ensureDir(path_1.dirname(nft));
83
76
  await fs_extra_1.default.writeFile(nft, json);
84
77
  }
85
- await updateFunctionsManifest({ vercelConfig, workPath, pages });
78
+ await updateFunctionsManifest({ workPath, pages });
86
79
  };
87
80
  }
88
81
  exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
@@ -110,10 +103,9 @@ async function readJson(filePath) {
110
103
  }
111
104
  /**
112
105
  * If `.output/functions-manifest.json` exists, append to the pages
113
- * property. Otherwise write a new file. This will also read `vercel.json`
114
- * and apply relevant `functions` property config.
106
+ * property. Otherwise write a new file.
115
107
  */
116
- async function updateFunctionsManifest({ vercelConfig, workPath, pages, }) {
108
+ async function updateFunctionsManifest({ workPath, pages, }) {
117
109
  const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
118
110
  const functionsManifest = await readJson(functionsManifestPath);
119
111
  if (!functionsManifest.version)
@@ -121,16 +113,7 @@ async function updateFunctionsManifest({ vercelConfig, workPath, pages, }) {
121
113
  if (!functionsManifest.pages)
122
114
  functionsManifest.pages = {};
123
115
  for (const [pageKey, pageConfig] of Object.entries(pages)) {
124
- const fnConfig = await lambda_1.getLambdaOptionsFromFunction({
125
- sourceFile: pageKey,
126
- config: vercelConfig,
127
- });
128
- functionsManifest.pages[pageKey] = {
129
- ...pageConfig,
130
- memory: fnConfig.memory || pageConfig.memory,
131
- maxDuration: fnConfig.maxDuration || pageConfig.maxDuration,
132
- regions: vercelConfig.regions || pageConfig.regions,
133
- };
116
+ functionsManifest.pages[pageKey] = { ...pageConfig };
134
117
  }
135
118
  await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
136
119
  }
package/dist/index.js CHANGED
@@ -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,21 @@ 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({ vercelConfig, workPath, }) {
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
- includeFiles: config.includeFiles,
32316
- excludeFiles: config.excludeFiles,
32317
32311
  },
32318
32312
  meta: {
32319
32313
  avoidTopLevelInstall: true,
@@ -32326,7 +32320,6 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
32326
32320
  maxDuration: output.maxDuration,
32327
32321
  environment: output.environment,
32328
32322
  allowQuery: output.allowQuery,
32329
- //regions: output.regions,
32330
32323
  };
32331
32324
  // @ts-ignore This symbol is a private API
32332
32325
  const lambdaFiles = output[lambda_1.FILES_SYMBOL];
@@ -32359,7 +32352,7 @@ function convertRuntimeToPlugin(buildRuntime, ext) {
32359
32352
  await fs_extra_1.default.ensureDir(path_1.dirname(nft));
32360
32353
  await fs_extra_1.default.writeFile(nft, json);
32361
32354
  }
32362
- await updateFunctionsManifest({ vercelConfig, workPath, pages });
32355
+ await updateFunctionsManifest({ workPath, pages });
32363
32356
  };
32364
32357
  }
32365
32358
  exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
@@ -32387,10 +32380,9 @@ async function readJson(filePath) {
32387
32380
  }
32388
32381
  /**
32389
32382
  * If `.output/functions-manifest.json` exists, append to the pages
32390
- * property. Otherwise write a new file. This will also read `vercel.json`
32391
- * and apply relevant `functions` property config.
32383
+ * property. Otherwise write a new file.
32392
32384
  */
32393
- async function updateFunctionsManifest({ vercelConfig, workPath, pages, }) {
32385
+ async function updateFunctionsManifest({ workPath, pages, }) {
32394
32386
  const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
32395
32387
  const functionsManifest = await readJson(functionsManifestPath);
32396
32388
  if (!functionsManifest.version)
@@ -32398,16 +32390,7 @@ async function updateFunctionsManifest({ vercelConfig, workPath, pages, }) {
32398
32390
  if (!functionsManifest.pages)
32399
32391
  functionsManifest.pages = {};
32400
32392
  for (const [pageKey, pageConfig] of Object.entries(pages)) {
32401
- const fnConfig = await lambda_1.getLambdaOptionsFromFunction({
32402
- sourceFile: pageKey,
32403
- config: vercelConfig,
32404
- });
32405
- functionsManifest.pages[pageKey] = {
32406
- ...pageConfig,
32407
- memory: fnConfig.memory || pageConfig.memory,
32408
- maxDuration: fnConfig.maxDuration || pageConfig.maxDuration,
32409
- regions: vercelConfig.regions || pageConfig.regions,
32410
- };
32393
+ functionsManifest.pages[pageKey] = { ...pageConfig };
32411
32394
  }
32412
32395
  await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
32413
32396
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.12.3-canary.26",
3
+ "version": "2.12.3-canary.27",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -49,5 +49,5 @@
49
49
  "typescript": "4.3.4",
50
50
  "yazl": "2.4.3"
51
51
  },
52
- "gitHead": "1202ff7b2b8a821c6404a86baa12996f3078ed36"
52
+ "gitHead": "5499fa9a042ef4f44cd4a48f2a168bf5c6d164f5"
53
53
  }