@vercel/build-utils 2.12.3-canary.15 → 2.12.3-canary.19

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.
@@ -7,6 +7,17 @@ import type { BuildOptions } from './types';
7
7
  */
8
8
  export declare function convertRuntimeToPlugin(buildRuntime: (options: BuildOptions) => Promise<{
9
9
  output: Lambda;
10
- }>, ext: string): Promise<({ workPath }: {
10
+ }>, ext: string): ({ workPath }: {
11
11
  workPath: string;
12
- }) => Promise<void>>;
12
+ }) => Promise<void>;
13
+ /**
14
+ * If `.output/functions-manifest.json` exists, append to the pages
15
+ * property. Otherwise write a new file. This will also read `vercel.json`
16
+ * and apply relevant `functions` property config.
17
+ */
18
+ export declare function updateFunctionsManifest({ workPath, pages, }: {
19
+ workPath: string;
20
+ pages: {
21
+ [key: string]: any;
22
+ };
23
+ }): Promise<void>;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.convertRuntimeToPlugin = void 0;
6
+ exports.updateFunctionsManifest = exports.convertRuntimeToPlugin = void 0;
7
7
  const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = require("path");
9
9
  const glob_1 = __importDefault(require("./fs/glob"));
@@ -15,14 +15,14 @@ const minimatch_1 = __importDefault(require("minimatch"));
15
15
  * @param buildRuntime - a legacy build() function from a Runtime
16
16
  * @param ext - the file extension, for example `.py`
17
17
  */
18
- async function convertRuntimeToPlugin(buildRuntime, ext) {
18
+ function convertRuntimeToPlugin(buildRuntime, ext) {
19
19
  return async function build({ workPath }) {
20
20
  const opts = { cwd: workPath };
21
21
  const files = await glob_1.default('**', opts);
22
22
  delete files['vercel.json']; // Builders/Runtimes didn't have vercel.json
23
23
  const entrypoints = await glob_1.default(`api/**/*${ext}`, opts);
24
- const functionsManifest = {};
25
- const functions = await readVercelConfigFunctions(workPath);
24
+ const pages = {};
25
+ const { functions = {} } = await readVercelConfig(workPath);
26
26
  const traceDir = path_1.join(workPath, '.output', 'runtime-traced-files');
27
27
  await fs_extra_1.default.ensureDir(traceDir);
28
28
  for (const entrypoint of Object.keys(entrypoints)) {
@@ -38,11 +38,11 @@ async function convertRuntimeToPlugin(buildRuntime, ext) {
38
38
  excludeFiles: config.excludeFiles,
39
39
  },
40
40
  });
41
- functionsManifest[entrypoint] = {
41
+ pages[entrypoint] = {
42
42
  handler: output.handler,
43
43
  runtime: output.runtime,
44
- memory: config.memory || output.memory,
45
- maxDuration: config.maxDuration || output.maxDuration,
44
+ memory: output.memory,
45
+ maxDuration: output.maxDuration,
46
46
  environment: output.environment,
47
47
  allowQuery: output.allowQuery,
48
48
  regions: output.regions,
@@ -78,7 +78,7 @@ async function convertRuntimeToPlugin(buildRuntime, ext) {
78
78
  await fs_extra_1.default.ensureDir(path_1.dirname(nft));
79
79
  await fs_extra_1.default.writeFile(nft, json);
80
80
  }
81
- await fs_extra_1.default.writeFile(path_1.join(workPath, '.output', 'functions-manifest.json'), JSON.stringify(functionsManifest));
81
+ await updateFunctionsManifest({ workPath, pages });
82
82
  };
83
83
  }
84
84
  exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
@@ -92,12 +92,10 @@ async function linkOrCopy(existingPath, newPath) {
92
92
  }
93
93
  }
94
94
  }
95
- async function readVercelConfigFunctions(workPath) {
96
- const vercelJsonPath = path_1.join(workPath, 'vercel.json');
95
+ async function readJson(filePath) {
97
96
  try {
98
- const str = await fs_extra_1.default.readFile(vercelJsonPath, 'utf8');
99
- const obj = JSON.parse(str);
100
- return obj.functions || {};
97
+ const str = await fs_extra_1.default.readFile(filePath, 'utf8');
98
+ return JSON.parse(str);
101
99
  }
102
100
  catch (err) {
103
101
  if (err.code === 'ENOENT') {
@@ -106,3 +104,35 @@ async function readVercelConfigFunctions(workPath) {
106
104
  throw err;
107
105
  }
108
106
  }
107
+ async function readVercelConfig(workPath) {
108
+ const vercelJsonPath = path_1.join(workPath, 'vercel.json');
109
+ return readJson(vercelJsonPath);
110
+ }
111
+ /**
112
+ * 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.
115
+ */
116
+ async function updateFunctionsManifest({ workPath, pages, }) {
117
+ const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
118
+ const vercelConfig = await readVercelConfig(workPath);
119
+ const functionsManifest = await readJson(functionsManifestPath);
120
+ if (!functionsManifest.version)
121
+ functionsManifest.version = 1;
122
+ if (!functionsManifest.pages)
123
+ functionsManifest.pages = {};
124
+ for (const [pageKey, pageConfig] of Object.entries(pages)) {
125
+ const fnConfig = await lambda_1.getLambdaOptionsFromFunction({
126
+ sourceFile: pageKey,
127
+ config: vercelConfig,
128
+ });
129
+ functionsManifest.pages[pageKey] = {
130
+ ...pageConfig,
131
+ memory: fnConfig.memory || pageConfig.memory,
132
+ maxDuration: fnConfig.maxDuration || pageConfig.maxDuration,
133
+ regions: vercelConfig.regions || pageConfig.regions,
134
+ };
135
+ }
136
+ await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
137
+ }
138
+ exports.updateFunctionsManifest = updateFunctionsManifest;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,7 @@ export { detectFramework } from './detect-framework';
18
18
  export { DetectorFilesystem } from './detectors/filesystem';
19
19
  export { readConfigFile } from './fs/read-config-file';
20
20
  export { normalizePath } from './fs/normalize-path';
21
+ export { convertRuntimeToPlugin, updateFunctionsManifest, } from './convert-runtime-to-plugin';
21
22
  export * from './schemas';
22
23
  export * from './types';
23
24
  export * from './errors';
package/dist/index.js CHANGED
@@ -26130,6 +26130,7 @@ exports.frameworks = [
26130
26130
  },
26131
26131
  buildCommand: {
26132
26132
  placeholder: '`npm run build` or `blitz build`',
26133
+ value: 'blitz build',
26133
26134
  },
26134
26135
  devCommand: {
26135
26136
  value: 'blitz start',
@@ -26138,8 +26139,6 @@ exports.frameworks = [
26138
26139
  placeholder: 'Next.js default',
26139
26140
  },
26140
26141
  },
26141
- devCommand: 'blitz start',
26142
- buildCommand: 'blitz build',
26143
26142
  getFsOutputDir: async () => '.next',
26144
26143
  getOutputDirName: async () => 'public',
26145
26144
  },
@@ -26168,6 +26167,7 @@ exports.frameworks = [
26168
26167
  },
26169
26168
  buildCommand: {
26170
26169
  placeholder: '`npm run build` or `next build`',
26170
+ value: 'next build',
26171
26171
  },
26172
26172
  devCommand: {
26173
26173
  value: 'next dev --port $PORT',
@@ -26183,8 +26183,6 @@ exports.frameworks = [
26183
26183
  dependencies: ['next-plugin-sentry', 'next-sentry-source-maps'],
26184
26184
  },
26185
26185
  ],
26186
- devCommand: 'next dev --port $PORT',
26187
- buildCommand: 'next build',
26188
26186
  getFsOutputDir: async () => '.next',
26189
26187
  getOutputDirName: async () => 'public',
26190
26188
  cachePattern: '.next/cache/**',
@@ -26213,6 +26211,7 @@ exports.frameworks = [
26213
26211
  },
26214
26212
  buildCommand: {
26215
26213
  placeholder: '`npm run build` or `gatsby build`',
26214
+ value: 'gatsby build',
26216
26215
  },
26217
26216
  devCommand: {
26218
26217
  value: 'gatsby develop --port $PORT',
@@ -26223,8 +26222,6 @@ exports.frameworks = [
26223
26222
  },
26224
26223
  },
26225
26224
  dependency: 'gatsby',
26226
- devCommand: 'gatsby develop --port $PORT',
26227
- buildCommand: 'gatsby build',
26228
26225
  getOutputDirName: async () => 'public',
26229
26226
  getFsOutputDir: async () => 'public',
26230
26227
  defaultRoutes: async (dirPrefix) => {
@@ -26296,6 +26293,7 @@ exports.frameworks = [
26296
26293
  },
26297
26294
  buildCommand: {
26298
26295
  placeholder: '`npm run build` or `hexo generate`',
26296
+ value: 'hexo generate',
26299
26297
  },
26300
26298
  devCommand: {
26301
26299
  value: 'hexo server --port $PORT',
@@ -26306,8 +26304,6 @@ exports.frameworks = [
26306
26304
  },
26307
26305
  },
26308
26306
  dependency: 'hexo',
26309
- devCommand: 'hexo server --port $PORT',
26310
- buildCommand: 'hexo generate',
26311
26307
  getFsOutputDir: async () => 'public',
26312
26308
  getOutputDirName: async () => 'public',
26313
26309
  },
@@ -26334,6 +26330,7 @@ exports.frameworks = [
26334
26330
  },
26335
26331
  buildCommand: {
26336
26332
  placeholder: '`npm run build` or `npx @11ty/eleventy`',
26333
+ value: 'npx @11ty/eleventy',
26337
26334
  },
26338
26335
  devCommand: {
26339
26336
  value: 'npx @11ty/eleventy --serve --watch --port $PORT',
@@ -26344,8 +26341,6 @@ exports.frameworks = [
26344
26341
  },
26345
26342
  },
26346
26343
  dependency: '@11ty/eleventy',
26347
- devCommand: 'npx @11ty/eleventy --serve --watch --port $PORT',
26348
- buildCommand: 'npx @11ty/eleventy',
26349
26344
  getFsOutputDir: async () => '_site',
26350
26345
  getOutputDirName: async () => '_site',
26351
26346
  cachePattern: '.cache/**',
@@ -26372,6 +26367,7 @@ exports.frameworks = [
26372
26367
  },
26373
26368
  buildCommand: {
26374
26369
  placeholder: '`npm run build` or `docusaurus build`',
26370
+ value: 'docusaurus build',
26375
26371
  },
26376
26372
  devCommand: {
26377
26373
  value: 'docusaurus start --port $PORT',
@@ -26382,8 +26378,6 @@ exports.frameworks = [
26382
26378
  },
26383
26379
  },
26384
26380
  dependency: '@docusaurus/core',
26385
- devCommand: 'docusaurus start --port $PORT',
26386
- buildCommand: 'docusaurus build',
26387
26381
  getFsOutputDir: async (dirPrefix) => {
26388
26382
  const base = 'build';
26389
26383
  try {
@@ -26517,6 +26511,7 @@ exports.frameworks = [
26517
26511
  },
26518
26512
  buildCommand: {
26519
26513
  placeholder: '`npm run build` or `docusaurus-build`',
26514
+ value: 'docusaurus-build',
26520
26515
  },
26521
26516
  devCommand: {
26522
26517
  value: 'docusaurus-start --port $PORT',
@@ -26527,8 +26522,6 @@ exports.frameworks = [
26527
26522
  },
26528
26523
  },
26529
26524
  dependency: 'docusaurus',
26530
- devCommand: 'docusaurus-start --port $PORT',
26531
- buildCommand: 'docusaurus-build',
26532
26525
  getFsOutputDir: async (dirPrefix) => {
26533
26526
  const base = 'build';
26534
26527
  try {
@@ -26582,6 +26575,7 @@ exports.frameworks = [
26582
26575
  },
26583
26576
  buildCommand: {
26584
26577
  placeholder: '`npm run build` or `preact build`',
26578
+ value: 'preact build',
26585
26579
  },
26586
26580
  devCommand: {
26587
26581
  value: 'preact watch --port $PORT',
@@ -26592,8 +26586,6 @@ exports.frameworks = [
26592
26586
  },
26593
26587
  },
26594
26588
  dependency: 'preact-cli',
26595
- devCommand: 'preact watch --port $PORT',
26596
- buildCommand: 'preact build',
26597
26589
  getFsOutputDir: async () => 'build',
26598
26590
  getOutputDirName: async () => 'build',
26599
26591
  defaultRoutes: [
@@ -26638,6 +26630,7 @@ exports.frameworks = [
26638
26630
  },
26639
26631
  buildCommand: {
26640
26632
  placeholder: '`npm run build` or `dojo build`',
26633
+ value: 'dojo build',
26641
26634
  },
26642
26635
  devCommand: {
26643
26636
  value: 'dojo build -m dev -w -s -p $PORT',
@@ -26648,8 +26641,6 @@ exports.frameworks = [
26648
26641
  },
26649
26642
  },
26650
26643
  dependency: '@dojo/cli',
26651
- devCommand: 'dojo build -m dev -w -s -p $PORT',
26652
- buildCommand: 'dojo build',
26653
26644
  getFsOutputDir: async () => 'output/dist',
26654
26645
  getOutputDirName: async () => path_1.join('output', 'dist'),
26655
26646
  defaultRoutes: [
@@ -26704,6 +26695,7 @@ exports.frameworks = [
26704
26695
  },
26705
26696
  buildCommand: {
26706
26697
  placeholder: '`npm run build` or `ember build`',
26698
+ value: 'ember build',
26707
26699
  },
26708
26700
  devCommand: {
26709
26701
  value: 'ember serve --port $PORT',
@@ -26714,8 +26706,6 @@ exports.frameworks = [
26714
26706
  },
26715
26707
  },
26716
26708
  dependency: 'ember-cli',
26717
- devCommand: 'ember serve --port $PORT',
26718
- buildCommand: 'ember build',
26719
26709
  getFsOutputDir: async () => 'dist',
26720
26710
  getOutputDirName: async () => 'dist',
26721
26711
  defaultRoutes: [
@@ -26758,6 +26748,7 @@ exports.frameworks = [
26758
26748
  },
26759
26749
  buildCommand: {
26760
26750
  placeholder: '`npm run build` or `vue-cli-service build`',
26751
+ value: 'vue-cli-service build',
26761
26752
  },
26762
26753
  devCommand: {
26763
26754
  value: 'vue-cli-service serve --port $PORT',
@@ -26768,8 +26759,6 @@ exports.frameworks = [
26768
26759
  },
26769
26760
  },
26770
26761
  dependency: '@vue/cli-service',
26771
- devCommand: 'vue-cli-service serve --port $PORT',
26772
- buildCommand: 'vue-cli-service build',
26773
26762
  getFsOutputDir: async () => 'dist',
26774
26763
  getOutputDirName: async () => 'dist',
26775
26764
  defaultRoutes: [
@@ -26835,6 +26824,7 @@ exports.frameworks = [
26835
26824
  },
26836
26825
  buildCommand: {
26837
26826
  placeholder: '`npm run build` or `ng build && scully`',
26827
+ value: 'ng build && scully',
26838
26828
  },
26839
26829
  devCommand: {
26840
26830
  value: 'ng serve --port $PORT',
@@ -26845,8 +26835,6 @@ exports.frameworks = [
26845
26835
  },
26846
26836
  },
26847
26837
  dependency: '@scullyio/init',
26848
- devCommand: 'ng serve --port $PORT',
26849
- buildCommand: 'ng build && scully',
26850
26838
  getFsOutputDir: async () => 'dist',
26851
26839
  getOutputDirName: async () => 'dist/static',
26852
26840
  },
@@ -26872,6 +26860,7 @@ exports.frameworks = [
26872
26860
  },
26873
26861
  buildCommand: {
26874
26862
  placeholder: '`npm run build` or `ng build`',
26863
+ value: 'ng build',
26875
26864
  },
26876
26865
  devCommand: {
26877
26866
  value: 'ng serve --port $PORT',
@@ -26881,8 +26870,6 @@ exports.frameworks = [
26881
26870
  },
26882
26871
  },
26883
26872
  dependency: '@ionic/angular',
26884
- devCommand: 'ng serve --port $PORT',
26885
- buildCommand: 'ng build',
26886
26873
  getFsOutputDir: async () => 'www',
26887
26874
  getOutputDirName: async () => 'www',
26888
26875
  defaultRoutes: [
@@ -26924,6 +26911,7 @@ exports.frameworks = [
26924
26911
  },
26925
26912
  buildCommand: {
26926
26913
  placeholder: '`npm run build` or `ng build`',
26914
+ value: 'ng build',
26927
26915
  },
26928
26916
  devCommand: {
26929
26917
  value: 'ng serve --port $PORT',
@@ -26934,8 +26922,6 @@ exports.frameworks = [
26934
26922
  },
26935
26923
  },
26936
26924
  dependency: '@angular/cli',
26937
- devCommand: 'ng serve --port $PORT',
26938
- buildCommand: 'ng build',
26939
26925
  getFsOutputDir: async () => 'dist',
26940
26926
  getOutputDirName: async (dirPrefix) => {
26941
26927
  const base = 'dist';
@@ -26991,6 +26977,7 @@ exports.frameworks = [
26991
26977
  },
26992
26978
  buildCommand: {
26993
26979
  placeholder: '`npm run build` or `polymer build`',
26980
+ value: 'polymer build',
26994
26981
  },
26995
26982
  devCommand: {
26996
26983
  value: 'polymer serve --port $PORT',
@@ -27001,8 +26988,6 @@ exports.frameworks = [
27001
26988
  },
27002
26989
  },
27003
26990
  dependency: 'polymer-cli',
27004
- devCommand: 'polymer serve --port $PORT',
27005
- buildCommand: 'polymer build',
27006
26991
  getFsOutputDir: async () => 'build',
27007
26992
  getOutputDirName: async (dirPrefix) => {
27008
26993
  const base = 'build';
@@ -27060,6 +27045,7 @@ exports.frameworks = [
27060
27045
  },
27061
27046
  buildCommand: {
27062
27047
  placeholder: '`npm run build` or `rollup -c`',
27048
+ value: 'rollup -c',
27063
27049
  },
27064
27050
  devCommand: {
27065
27051
  value: 'rollup -c -w',
@@ -27069,8 +27055,6 @@ exports.frameworks = [
27069
27055
  },
27070
27056
  },
27071
27057
  dependency: 'sirv-cli',
27072
- devCommand: 'rollup -c -w',
27073
- buildCommand: 'rollup -c',
27074
27058
  getFsOutputDir: async () => 'public',
27075
27059
  getOutputDirName: async () => 'public',
27076
27060
  defaultRoutes: [
@@ -27112,6 +27096,7 @@ exports.frameworks = [
27112
27096
  },
27113
27097
  buildCommand: {
27114
27098
  placeholder: '`npm run build` or `svelte-kit build`',
27099
+ value: 'svelte-kit build',
27115
27100
  },
27116
27101
  devCommand: {
27117
27102
  value: 'svelte-kit dev --port $PORT',
@@ -27121,8 +27106,6 @@ exports.frameworks = [
27121
27106
  placeholder: 'public',
27122
27107
  },
27123
27108
  },
27124
- devCommand: 'svelte-kit dev --port $PORT',
27125
- buildCommand: 'svelte-kit build',
27126
27109
  getFsOutputDir: async () => '.output',
27127
27110
  getOutputDirName: async () => 'public',
27128
27111
  },
@@ -27148,6 +27131,7 @@ exports.frameworks = [
27148
27131
  },
27149
27132
  buildCommand: {
27150
27133
  placeholder: '`npm run build` or `react-scripts build`',
27134
+ value: 'react-scripts build',
27151
27135
  },
27152
27136
  devCommand: {
27153
27137
  value: 'react-scripts start',
@@ -27157,8 +27141,6 @@ exports.frameworks = [
27157
27141
  },
27158
27142
  },
27159
27143
  dependency: '@ionic/react',
27160
- devCommand: 'react-scripts start',
27161
- buildCommand: 'react-scripts build',
27162
27144
  getFsOutputDir: async () => 'build',
27163
27145
  getOutputDirName: async () => 'build',
27164
27146
  defaultRoutes: [
@@ -27253,6 +27235,7 @@ exports.frameworks = [
27253
27235
  },
27254
27236
  buildCommand: {
27255
27237
  placeholder: '`npm run build` or `react-scripts build`',
27238
+ value: 'react-scripts build',
27256
27239
  },
27257
27240
  devCommand: {
27258
27241
  value: 'react-scripts start',
@@ -27262,8 +27245,6 @@ exports.frameworks = [
27262
27245
  },
27263
27246
  },
27264
27247
  dependency: 'react-scripts',
27265
- devCommand: 'react-scripts start',
27266
- buildCommand: 'react-scripts build',
27267
27248
  getFsOutputDir: async () => 'build',
27268
27249
  getOutputDirName: async () => 'build',
27269
27250
  defaultRoutes: [
@@ -27353,6 +27334,7 @@ exports.frameworks = [
27353
27334
  },
27354
27335
  buildCommand: {
27355
27336
  placeholder: '`npm run build` or `gridsome build`',
27337
+ value: 'gridsome build',
27356
27338
  },
27357
27339
  devCommand: {
27358
27340
  value: 'gridsome develop -p $PORT',
@@ -27363,8 +27345,6 @@ exports.frameworks = [
27363
27345
  },
27364
27346
  },
27365
27347
  dependency: 'gridsome',
27366
- devCommand: 'gridsome develop -p $PORT',
27367
- buildCommand: 'gridsome build',
27368
27348
  getFsOutputDir: async () => 'dist',
27369
27349
  getOutputDirName: async () => 'dist',
27370
27350
  },
@@ -27390,6 +27370,7 @@ exports.frameworks = [
27390
27370
  },
27391
27371
  buildCommand: {
27392
27372
  placeholder: '`npm run build` or `umi build`',
27373
+ value: 'umi build',
27393
27374
  },
27394
27375
  devCommand: {
27395
27376
  value: 'umi dev --port $PORT',
@@ -27400,8 +27381,6 @@ exports.frameworks = [
27400
27381
  },
27401
27382
  },
27402
27383
  dependency: 'umi',
27403
- devCommand: 'umi dev --port $PORT',
27404
- buildCommand: 'umi build',
27405
27384
  getFsOutputDir: async () => 'dist',
27406
27385
  getOutputDirName: async () => 'dist',
27407
27386
  defaultRoutes: [
@@ -27443,6 +27422,7 @@ exports.frameworks = [
27443
27422
  },
27444
27423
  buildCommand: {
27445
27424
  placeholder: '`npm run build` or `sapper export`',
27425
+ value: 'sapper export',
27446
27426
  },
27447
27427
  devCommand: {
27448
27428
  value: 'sapper dev --port $PORT',
@@ -27453,8 +27433,6 @@ exports.frameworks = [
27453
27433
  },
27454
27434
  },
27455
27435
  dependency: 'sapper',
27456
- devCommand: 'sapper dev --port $PORT',
27457
- buildCommand: 'sapper export',
27458
27436
  getFsOutputDir: async () => '__sapper__/export',
27459
27437
  getOutputDirName: async () => '__sapper__/export',
27460
27438
  },
@@ -27480,6 +27458,7 @@ exports.frameworks = [
27480
27458
  },
27481
27459
  buildCommand: {
27482
27460
  placeholder: '`npm run build` or `saber build`',
27461
+ value: 'saber build',
27483
27462
  },
27484
27463
  devCommand: {
27485
27464
  value: 'saber --port $PORT',
@@ -27490,8 +27469,6 @@ exports.frameworks = [
27490
27469
  },
27491
27470
  },
27492
27471
  dependency: 'saber',
27493
- devCommand: 'saber --port $PORT',
27494
- buildCommand: 'saber build',
27495
27472
  getFsOutputDir: async () => 'public',
27496
27473
  getOutputDirName: async () => 'public',
27497
27474
  defaultRoutes: [
@@ -27548,6 +27525,7 @@ exports.frameworks = [
27548
27525
  },
27549
27526
  buildCommand: {
27550
27527
  placeholder: '`npm run build` or `stencil build`',
27528
+ value: 'stencil build',
27551
27529
  },
27552
27530
  devCommand: {
27553
27531
  value: 'stencil build --dev --watch --serve --port $PORT',
@@ -27558,8 +27536,6 @@ exports.frameworks = [
27558
27536
  },
27559
27537
  },
27560
27538
  dependency: '@stencil/core',
27561
- devCommand: 'stencil build --dev --watch --serve --port $PORT',
27562
- buildCommand: 'stencil build',
27563
27539
  getFsOutputDir: async () => 'www',
27564
27540
  getOutputDirName: async () => 'www',
27565
27541
  defaultRoutes: [
@@ -27636,6 +27612,7 @@ exports.frameworks = [
27636
27612
  },
27637
27613
  buildCommand: {
27638
27614
  placeholder: '`npm run build` or `nuxt generate`',
27615
+ value: 'nuxt generate',
27639
27616
  },
27640
27617
  devCommand: {
27641
27618
  value: 'nuxt',
@@ -27645,8 +27622,6 @@ exports.frameworks = [
27645
27622
  },
27646
27623
  },
27647
27624
  dependency: 'nuxt',
27648
- devCommand: 'nuxt',
27649
- buildCommand: 'nuxt generate',
27650
27625
  getFsOutputDir: async () => '.output',
27651
27626
  getOutputDirName: async () => 'dist',
27652
27627
  cachePattern: '.nuxt/**',
@@ -27704,8 +27679,6 @@ exports.frameworks = [
27704
27679
  placeholder: 'RedwoodJS default',
27705
27680
  },
27706
27681
  },
27707
- devCommand: 'yarn rw dev --fwd="--port=$PORT --open=false',
27708
- buildCommand: 'yarn rw deploy vercel',
27709
27682
  getFsOutputDir: async () => 'public',
27710
27683
  getOutputDirName: async () => 'public',
27711
27684
  },
@@ -27740,6 +27713,7 @@ exports.frameworks = [
27740
27713
  },
27741
27714
  buildCommand: {
27742
27715
  placeholder: '`npm run build` or `hugo -D --gc`',
27716
+ value: 'hugo -D --gc',
27743
27717
  },
27744
27718
  devCommand: {
27745
27719
  value: 'hugo server -D -w -p $PORT',
@@ -27749,8 +27723,6 @@ exports.frameworks = [
27749
27723
  placeholder: '`public` or `publishDir` from the `config` file',
27750
27724
  },
27751
27725
  },
27752
- devCommand: 'hugo server -D -w -p $PORT',
27753
- buildCommand: 'hugo -D --gc',
27754
27726
  getFsOutputDir: async (dirPrefix) => {
27755
27727
  const config = await read_config_file_1.readConfigFile(['config.json', 'config.yaml', 'config.toml'].map(fileName => {
27756
27728
  return path_1.join(dirPrefix, fileName);
@@ -27786,6 +27758,7 @@ exports.frameworks = [
27786
27758
  },
27787
27759
  buildCommand: {
27788
27760
  placeholder: '`npm run build` or `jekyll build`',
27761
+ value: 'jekyll build',
27789
27762
  },
27790
27763
  devCommand: {
27791
27764
  value: 'bundle exec jekyll serve --watch --port $PORT',
@@ -27795,8 +27768,6 @@ exports.frameworks = [
27795
27768
  placeholder: '`_site` or `destination` from `_config.yml`',
27796
27769
  },
27797
27770
  },
27798
- devCommand: 'bundle exec jekyll serve --watch --port $PORT',
27799
- buildCommand: 'jekyll build',
27800
27771
  getFsOutputDir: async (dirPrefix) => {
27801
27772
  const config = await read_config_file_1.readConfigFile(path_1.join(dirPrefix, '_config.yml'));
27802
27773
  return (config && config.destination) || '_site';
@@ -27828,6 +27799,7 @@ exports.frameworks = [
27828
27799
  },
27829
27800
  buildCommand: {
27830
27801
  placeholder: '`npm run build` or `brunch build --production`',
27802
+ value: 'brunch build --production',
27831
27803
  },
27832
27804
  devCommand: {
27833
27805
  value: 'brunch watch --server --port $PORT',
@@ -27837,8 +27809,6 @@ exports.frameworks = [
27837
27809
  value: 'public',
27838
27810
  },
27839
27811
  },
27840
- devCommand: 'brunch watch --server --port $PORT',
27841
- buildCommand: 'brunch build --production',
27842
27812
  getFsOutputDir: async () => 'public',
27843
27813
  getOutputDirName: async () => 'public',
27844
27814
  },
@@ -27862,18 +27832,17 @@ exports.frameworks = [
27862
27832
  value: 'bundle install',
27863
27833
  },
27864
27834
  buildCommand: {
27865
- value: '`npm run build` or `bundle exec middleman build`',
27835
+ placeholder: '`npm run build` or `bundle exec middleman build`',
27836
+ value: 'bundle exec middleman build',
27866
27837
  },
27867
27838
  devCommand: {
27868
- value: 'bundle exec middleman server -p $PORT',
27869
27839
  placeholder: 'bundle exec middleman server',
27840
+ value: 'bundle exec middleman server -p $PORT',
27870
27841
  },
27871
27842
  outputDirectory: {
27872
27843
  value: 'build',
27873
27844
  },
27874
27845
  },
27875
- devCommand: 'bundle exec middleman server -p $PORT',
27876
- buildCommand: 'bundle exec middleman build',
27877
27846
  getFsOutputDir: async () => 'build',
27878
27847
  getOutputDirName: async () => 'build',
27879
27848
  cachePattern: '{vendor/bin,vendor/cache,vendor/bundle}/**',
@@ -27902,15 +27871,13 @@ exports.frameworks = [
27902
27871
  value: 'zola build',
27903
27872
  },
27904
27873
  devCommand: {
27905
- value: 'zola serve --port $PORT',
27906
27874
  placeholder: 'zola serve',
27875
+ value: 'zola serve --port $PORT',
27907
27876
  },
27908
27877
  outputDirectory: {
27909
27878
  value: 'public',
27910
27879
  },
27911
27880
  },
27912
- devCommand: 'zola serve --port $PORT',
27913
- buildCommand: 'zola build',
27914
27881
  getFsOutputDir: async () => 'public',
27915
27882
  getOutputDirName: async () => 'public',
27916
27883
  defaultVersion: '0.13.0',
@@ -27938,17 +27905,17 @@ exports.frameworks = [
27938
27905
  },
27939
27906
  buildCommand: {
27940
27907
  placeholder: '`npm run build` or `vite build`',
27908
+ value: 'vite build',
27941
27909
  },
27942
27910
  devCommand: {
27943
27911
  placeholder: 'vite',
27912
+ value: 'vite',
27944
27913
  },
27945
27914
  outputDirectory: {
27946
27915
  value: 'dist',
27947
27916
  },
27948
27917
  },
27949
27918
  dependency: 'vite',
27950
- devCommand: 'vite',
27951
- buildCommand: 'vite build',
27952
27919
  getFsOutputDir: async () => 'dist',
27953
27920
  getOutputDirName: async () => 'dist',
27954
27921
  },
@@ -27974,17 +27941,17 @@ exports.frameworks = [
27974
27941
  },
27975
27942
  buildCommand: {
27976
27943
  placeholder: '`npm run build` or `parcel build`',
27944
+ value: 'parcel build',
27977
27945
  },
27978
27946
  devCommand: {
27979
27947
  placeholder: 'parcel',
27948
+ value: 'parcel',
27980
27949
  },
27981
27950
  outputDirectory: {
27982
- placeholder: 'dist',
27951
+ value: 'dist',
27983
27952
  },
27984
27953
  },
27985
27954
  dependency: 'parcel',
27986
- devCommand: 'parcel',
27987
- buildCommand: 'parcel build',
27988
27955
  getFsOutputDir: async () => 'dist',
27989
27956
  getOutputDirName: async () => 'dist',
27990
27957
  defaultRoutes: [
@@ -28018,16 +27985,16 @@ exports.frameworks = [
28018
27985
  },
28019
27986
  buildCommand: {
28020
27987
  placeholder: '`npm run vercel-build` or `npm run build`',
27988
+ value: null,
28021
27989
  },
28022
27990
  devCommand: {
28023
27991
  placeholder: 'None',
27992
+ value: null,
28024
27993
  },
28025
27994
  outputDirectory: {
28026
27995
  placeholder: '`public` if it exists, or `.`',
28027
27996
  },
28028
27997
  },
28029
- devCommand: null,
28030
- buildCommand: null,
28031
27998
  getFsOutputDir: async (dirPrefix) => {
28032
27999
  // Public if it exists or `.`
28033
28000
  let base = 'public';
@@ -32235,6 +32202,152 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', {
32235
32202
  });
32236
32203
 
32237
32204
 
32205
+ /***/ }),
32206
+
32207
+ /***/ 7276:
32208
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
32209
+
32210
+ "use strict";
32211
+
32212
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32213
+ return (mod && mod.__esModule) ? mod : { "default": mod };
32214
+ };
32215
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
32216
+ exports.updateFunctionsManifest = exports.convertRuntimeToPlugin = void 0;
32217
+ const fs_extra_1 = __importDefault(__webpack_require__(5392));
32218
+ const path_1 = __webpack_require__(5622);
32219
+ const glob_1 = __importDefault(__webpack_require__(4240));
32220
+ const normalize_path_1 = __webpack_require__(6261);
32221
+ const lambda_1 = __webpack_require__(6721);
32222
+ const minimatch_1 = __importDefault(__webpack_require__(9566));
32223
+ /**
32224
+ * Convert legacy Runtime to a Plugin.
32225
+ * @param buildRuntime - a legacy build() function from a Runtime
32226
+ * @param ext - the file extension, for example `.py`
32227
+ */
32228
+ function convertRuntimeToPlugin(buildRuntime, ext) {
32229
+ return async function build({ workPath }) {
32230
+ const opts = { cwd: workPath };
32231
+ const files = await glob_1.default('**', opts);
32232
+ delete files['vercel.json']; // Builders/Runtimes didn't have vercel.json
32233
+ const entrypoints = await glob_1.default(`api/**/*${ext}`, opts);
32234
+ const pages = {};
32235
+ const { functions = {} } = await readVercelConfig(workPath);
32236
+ const traceDir = path_1.join(workPath, '.output', 'runtime-traced-files');
32237
+ await fs_extra_1.default.ensureDir(traceDir);
32238
+ for (const entrypoint of Object.keys(entrypoints)) {
32239
+ const key = Object.keys(functions).find(src => src === entrypoint || minimatch_1.default(entrypoint, src)) || '';
32240
+ const config = functions[key] || {};
32241
+ const { output } = await buildRuntime({
32242
+ files,
32243
+ entrypoint,
32244
+ workPath,
32245
+ config: {
32246
+ zeroConfig: true,
32247
+ includeFiles: config.includeFiles,
32248
+ excludeFiles: config.excludeFiles,
32249
+ },
32250
+ });
32251
+ pages[entrypoint] = {
32252
+ handler: output.handler,
32253
+ runtime: output.runtime,
32254
+ memory: output.memory,
32255
+ maxDuration: output.maxDuration,
32256
+ environment: output.environment,
32257
+ allowQuery: output.allowQuery,
32258
+ regions: output.regions,
32259
+ };
32260
+ // @ts-ignore This symbol is a private API
32261
+ const lambdaFiles = output[lambda_1.FILES_SYMBOL];
32262
+ const entry = path_1.join(workPath, '.output', 'server', 'pages', entrypoint);
32263
+ await fs_extra_1.default.ensureDir(path_1.dirname(entry));
32264
+ await linkOrCopy(files[entrypoint].fsPath, entry);
32265
+ const tracedFiles = [];
32266
+ Object.entries(lambdaFiles).forEach(async ([relPath, file]) => {
32267
+ const newPath = path_1.join(traceDir, relPath);
32268
+ tracedFiles.push({ absolutePath: newPath, relativePath: relPath });
32269
+ if (file.fsPath) {
32270
+ await linkOrCopy(file.fsPath, newPath);
32271
+ }
32272
+ else if (file.type === 'FileBlob') {
32273
+ const { data, mode } = file;
32274
+ await fs_extra_1.default.writeFile(newPath, data, { mode });
32275
+ }
32276
+ else {
32277
+ throw new Error(`Unknown file type: ${file.type}`);
32278
+ }
32279
+ });
32280
+ const nft = path_1.join(workPath, '.output', 'server', 'pages', `${entrypoint}.nft.json`);
32281
+ const json = JSON.stringify({
32282
+ version: 1,
32283
+ files: tracedFiles.map(f => ({
32284
+ input: normalize_path_1.normalizePath(path_1.relative(nft, f.absolutePath)),
32285
+ output: normalize_path_1.normalizePath(f.relativePath),
32286
+ })),
32287
+ });
32288
+ await fs_extra_1.default.ensureDir(path_1.dirname(nft));
32289
+ await fs_extra_1.default.writeFile(nft, json);
32290
+ }
32291
+ await updateFunctionsManifest({ workPath, pages });
32292
+ };
32293
+ }
32294
+ exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
32295
+ async function linkOrCopy(existingPath, newPath) {
32296
+ try {
32297
+ await fs_extra_1.default.createLink(existingPath, newPath);
32298
+ }
32299
+ catch (err) {
32300
+ if (err.code !== 'EEXIST') {
32301
+ await fs_extra_1.default.copyFile(existingPath, newPath);
32302
+ }
32303
+ }
32304
+ }
32305
+ async function readJson(filePath) {
32306
+ try {
32307
+ const str = await fs_extra_1.default.readFile(filePath, 'utf8');
32308
+ return JSON.parse(str);
32309
+ }
32310
+ catch (err) {
32311
+ if (err.code === 'ENOENT') {
32312
+ return {};
32313
+ }
32314
+ throw err;
32315
+ }
32316
+ }
32317
+ async function readVercelConfig(workPath) {
32318
+ const vercelJsonPath = path_1.join(workPath, 'vercel.json');
32319
+ return readJson(vercelJsonPath);
32320
+ }
32321
+ /**
32322
+ * If `.output/functions-manifest.json` exists, append to the pages
32323
+ * property. Otherwise write a new file. This will also read `vercel.json`
32324
+ * and apply relevant `functions` property config.
32325
+ */
32326
+ async function updateFunctionsManifest({ workPath, pages, }) {
32327
+ const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
32328
+ const vercelConfig = await readVercelConfig(workPath);
32329
+ const functionsManifest = await readJson(functionsManifestPath);
32330
+ if (!functionsManifest.version)
32331
+ functionsManifest.version = 1;
32332
+ if (!functionsManifest.pages)
32333
+ functionsManifest.pages = {};
32334
+ for (const [pageKey, pageConfig] of Object.entries(pages)) {
32335
+ const fnConfig = await lambda_1.getLambdaOptionsFromFunction({
32336
+ sourceFile: pageKey,
32337
+ config: vercelConfig,
32338
+ });
32339
+ functionsManifest.pages[pageKey] = {
32340
+ ...pageConfig,
32341
+ memory: fnConfig.memory || pageConfig.memory,
32342
+ maxDuration: fnConfig.maxDuration || pageConfig.maxDuration,
32343
+ regions: vercelConfig.regions || pageConfig.regions,
32344
+ };
32345
+ }
32346
+ await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
32347
+ }
32348
+ exports.updateFunctionsManifest = updateFunctionsManifest;
32349
+
32350
+
32238
32351
  /***/ }),
32239
32352
 
32240
32353
  /***/ 1868:
@@ -34205,7 +34318,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34205
34318
  return (mod && mod.__esModule) ? mod : { "default": mod };
34206
34319
  };
34207
34320
  Object.defineProperty(exports, "__esModule", ({ value: true }));
34208
- exports.getPlatformEnv = exports.isStaticRuntime = exports.isOfficialRuntime = exports.normalizePath = exports.readConfigFile = exports.DetectorFilesystem = exports.detectFramework = exports.detectApiExtensions = exports.detectApiDirectory = exports.detectOutputDirectory = exports.detectBuilders = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isSymbolicLink = exports.debug = exports.shouldServe = exports.streamToBuffer = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.runShellScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.getNodeBinPath = exports.walkParentDirs = exports.spawnCommand = exports.execCommand = exports.runPackageJsonScript = exports.installDependencies = exports.getScriptName = exports.spawnAsync = exports.execAsync = exports.rename = exports.glob = exports.getWriteableDirectory = exports.download = exports.Prerender = exports.createLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
34321
+ exports.getPlatformEnv = exports.isStaticRuntime = exports.isOfficialRuntime = exports.updateFunctionsManifest = exports.convertRuntimeToPlugin = exports.normalizePath = exports.readConfigFile = exports.DetectorFilesystem = exports.detectFramework = exports.detectApiExtensions = exports.detectApiDirectory = exports.detectOutputDirectory = exports.detectBuilders = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isSymbolicLink = exports.debug = exports.shouldServe = exports.streamToBuffer = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.runShellScript = exports.runPipInstall = exports.runBundleInstall = exports.runNpmInstall = exports.getNodeBinPath = exports.walkParentDirs = exports.spawnCommand = exports.execCommand = exports.runPackageJsonScript = exports.installDependencies = exports.getScriptName = exports.spawnAsync = exports.execAsync = exports.rename = exports.glob = exports.getWriteableDirectory = exports.download = exports.Prerender = exports.createLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
34209
34322
  const file_blob_1 = __importDefault(__webpack_require__(2397));
34210
34323
  exports.FileBlob = file_blob_1.default;
34211
34324
  const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
@@ -34267,6 +34380,9 @@ var read_config_file_1 = __webpack_require__(7792);
34267
34380
  Object.defineProperty(exports, "readConfigFile", ({ enumerable: true, get: function () { return read_config_file_1.readConfigFile; } }));
34268
34381
  var normalize_path_1 = __webpack_require__(6261);
34269
34382
  Object.defineProperty(exports, "normalizePath", ({ enumerable: true, get: function () { return normalize_path_1.normalizePath; } }));
34383
+ var convert_runtime_to_plugin_1 = __webpack_require__(7276);
34384
+ Object.defineProperty(exports, "convertRuntimeToPlugin", ({ enumerable: true, get: function () { return convert_runtime_to_plugin_1.convertRuntimeToPlugin; } }));
34385
+ Object.defineProperty(exports, "updateFunctionsManifest", ({ enumerable: true, get: function () { return convert_runtime_to_plugin_1.updateFunctionsManifest; } }));
34270
34386
  __exportStar(__webpack_require__(2416), exports);
34271
34387
  __exportStar(__webpack_require__(5748), exports);
34272
34388
  __exportStar(__webpack_require__(3983), exports);
package/dist/lambda.d.ts CHANGED
@@ -25,7 +25,7 @@ interface CreateLambdaOptions {
25
25
  }
26
26
  interface GetLambdaOptionsFromFunctionOptions {
27
27
  sourceFile: string;
28
- config?: Config;
28
+ config?: Pick<Config, 'functions'>;
29
29
  }
30
30
  export declare const FILES_SYMBOL: unique symbol;
31
31
  export declare class Lambda {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.12.3-canary.15",
3
+ "version": "2.12.3-canary.19",
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.10",
33
+ "@vercel/frameworks": "0.5.1-canary.12",
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": "a6ccf6c180c88f0d606a2fd932bbf558ab78ddeb"
52
+ "gitHead": "32664cd13b5d7a771d465a091bff2e966eed2f94"
53
53
  }