@vercel/build-utils 2.13.1-canary.0 → 2.13.1-canary.1

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.
@@ -26,7 +26,7 @@ ncc: Using typescript@4.3.4 (local user-provided)
26
26
  2kB dist/main/detectors/filesystem.d.ts
27
27
  2kB dist/main/convert-runtime-to-plugin.d.ts
28
28
  3kB dist/main/index.d.ts
29
- 3kB dist/main/fs/run-user-scripts.d.ts
29
+ 4kB dist/main/fs/run-user-scripts.d.ts
30
30
  9kB dist/main/types.d.ts
31
- 1244kB dist/main/index.js
32
- 1272kB [8092ms] - ncc 0.24.0
31
+ 1245kB dist/main/index.js
32
+ 1274kB [7772ms] - ncc 0.24.0
@@ -8,7 +8,6 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  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
- const lambda_1 = require("./lambda");
12
11
  const _1 = require(".");
13
12
  // `.output` was already created by the Build Command, so we have
14
13
  // to ensure its contents don't get bundled into the Lambda. Similarily,
@@ -92,8 +91,7 @@ function _experimental_convertRuntimeToPlugin(buildRuntime, packageName, ext) {
92
91
  skipDownload: true,
93
92
  },
94
93
  });
95
- // @ts-ignore This symbol is a private API
96
- const lambdaFiles = output[lambda_1.FILES_SYMBOL];
94
+ const lambdaFiles = output.files;
97
95
  // When deploying, the `files` that are passed to the Legacy Runtimes already
98
96
  // have certain files that are ignored stripped, but locally, that list of
99
97
  // files isn't used by the Legacy Runtimes, so we need to apply the filters
@@ -57,6 +57,22 @@ export declare function getNodeVersion(destPath: string, _nodeVersion?: string,
57
57
  export declare function scanParentDirs(destPath: string, readPackageJson?: boolean): Promise<ScanParentDirsResult>;
58
58
  export declare function walkParentDirs({ base, start, filename, }: WalkParentDirsProps): Promise<string | null>;
59
59
  export declare function runNpmInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta, nodeVersion?: NodeVersion): Promise<void>;
60
+ export declare function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }: {
61
+ cliType: CliType;
62
+ lockfileVersion: number | undefined;
63
+ nodeVersion: NodeVersion | undefined;
64
+ env: {
65
+ [x: string]: string | undefined;
66
+ };
67
+ }): {
68
+ [x: string]: string | undefined;
69
+ };
70
+ export declare function runCustomInstallCommand({ destPath, installCommand, nodeVersion, spawnOpts, }: {
71
+ destPath: string;
72
+ installCommand: string;
73
+ nodeVersion: NodeVersion;
74
+ spawnOpts?: SpawnOptions;
75
+ }): Promise<void>;
60
76
  export declare function runPackageJsonScript(destPath: string, scriptNames: string | Iterable<string>, spawnOpts?: SpawnOptions): Promise<boolean>;
61
77
  export declare function runBundleInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta): Promise<void>;
62
78
  export declare function runPipInstall(destPath: string, args?: string[], spawnOpts?: SpawnOptions, meta?: Meta): 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.installDependencies = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runPackageJsonScript = exports.runNpmInstall = exports.walkParentDirs = exports.scanParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.execAsync = exports.spawnAsync = void 0;
6
+ exports.installDependencies = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runPackageJsonScript = exports.runCustomInstallCommand = exports.getEnvForPackageManager = exports.runNpmInstall = exports.walkParentDirs = exports.scanParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.execAsync = exports.spawnAsync = void 0;
7
7
  const assert_1 = __importDefault(require("assert"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -221,36 +221,66 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
221
221
  const opts = { cwd: destPath, ...spawnOpts };
222
222
  const env = opts.env ? { ...opts.env } : { ...process.env };
223
223
  delete env.NODE_ENV;
224
- opts.env = env;
224
+ opts.env = getEnvForPackageManager({
225
+ cliType,
226
+ lockfileVersion,
227
+ nodeVersion,
228
+ env,
229
+ });
225
230
  let commandArgs;
226
231
  if (cliType === 'npm') {
227
232
  opts.prettyCommand = 'npm install';
228
233
  commandArgs = args
229
234
  .filter(a => a !== '--prefer-offline')
230
235
  .concat(['install', '--no-audit', '--unsafe-perm']);
231
- // If the lockfile version is 2 or greater and the node version is less than 16 than we will force npm7 to be used
236
+ }
237
+ else {
238
+ opts.prettyCommand = 'yarn install';
239
+ commandArgs = ['install', ...args];
240
+ }
241
+ if (process.env.NPM_ONLY_PRODUCTION) {
242
+ commandArgs.push('--production');
243
+ }
244
+ return spawnAsync(cliType, commandArgs, opts);
245
+ }
246
+ exports.runNpmInstall = runNpmInstall;
247
+ function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }) {
248
+ const newEnv = { ...env };
249
+ if (cliType === 'npm') {
232
250
  if (typeof lockfileVersion === 'number' &&
233
251
  lockfileVersion >= 2 &&
234
252
  ((nodeVersion === null || nodeVersion === void 0 ? void 0 : nodeVersion.major) || 0) < 16) {
235
253
  // Ensure that npm 7 is at the beginning of the `$PATH`
236
- env.PATH = `/node16/bin-npm7:${env.PATH}`;
254
+ newEnv.PATH = `/node16/bin-npm7:${env.PATH}`;
237
255
  console.log('Detected `package-lock.json` generated by npm 7...');
238
256
  }
239
257
  }
240
258
  else {
241
- opts.prettyCommand = 'yarn install';
242
- commandArgs = ['install', ...args];
243
259
  // Yarn v2 PnP mode may be activated, so force "node-modules" linker style
244
260
  if (!env.YARN_NODE_LINKER) {
245
- env.YARN_NODE_LINKER = 'node-modules';
261
+ newEnv.YARN_NODE_LINKER = 'node-modules';
246
262
  }
247
263
  }
248
- if (process.env.NPM_ONLY_PRODUCTION) {
249
- commandArgs.push('--production');
250
- }
251
- return spawnAsync(cliType, commandArgs, opts);
264
+ return newEnv;
252
265
  }
253
- exports.runNpmInstall = runNpmInstall;
266
+ exports.getEnvForPackageManager = getEnvForPackageManager;
267
+ async function runCustomInstallCommand({ destPath, installCommand, nodeVersion, spawnOpts, }) {
268
+ console.log(`Running "install" command: \`${installCommand}\`...`);
269
+ const { cliType, lockfileVersion } = await scanParentDirs(destPath);
270
+ const env = getEnvForPackageManager({
271
+ cliType,
272
+ lockfileVersion,
273
+ nodeVersion,
274
+ env: (spawnOpts === null || spawnOpts === void 0 ? void 0 : spawnOpts.env) || {},
275
+ });
276
+ debug_1.default(`Running with $PATH:`, (env === null || env === void 0 ? void 0 : env.PATH) || '');
277
+ await execCommand(installCommand, {
278
+ ...spawnOpts,
279
+ env,
280
+ cwd: destPath,
281
+ });
282
+ }
283
+ exports.runCustomInstallCommand = runCustomInstallCommand;
254
284
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
255
285
  assert_1.default(path_1.default.isAbsolute(destPath));
256
286
  const { packageJson, cliType, lockfileVersion } = await scanParentDirs(destPath, true);
@@ -259,21 +289,24 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
259
289
  return false;
260
290
  debug_1.default('Running user script...');
261
291
  const runScriptTime = Date.now();
262
- const opts = { cwd: destPath, ...spawnOpts };
263
- const env = (opts.env = { ...process.env, ...opts.env });
292
+ const opts = {
293
+ cwd: destPath,
294
+ ...spawnOpts,
295
+ env: getEnvForPackageManager({
296
+ cliType,
297
+ lockfileVersion,
298
+ nodeVersion: undefined,
299
+ env: {
300
+ ...process.env,
301
+ ...spawnOpts === null || spawnOpts === void 0 ? void 0 : spawnOpts.env,
302
+ },
303
+ }),
304
+ };
264
305
  if (cliType === 'npm') {
265
306
  opts.prettyCommand = `npm run ${scriptName}`;
266
- if (typeof lockfileVersion === 'number' && lockfileVersion >= 2) {
267
- // Ensure that npm 7 is at the beginning of the `$PATH`
268
- env.PATH = `/node16/bin-npm7:${env.PATH}`;
269
- }
270
307
  }
271
308
  else {
272
309
  opts.prettyCommand = `yarn run ${scriptName}`;
273
- // Yarn v2 PnP mode may be activated, so force "node-modules" linker style
274
- if (!env.YARN_NODE_LINKER) {
275
- env.YARN_NODE_LINKER = 'node-modules';
276
- }
277
310
  }
278
311
  console.log(`Running "${opts.prettyCommand}"`);
279
312
  await spawnAsync(cliType, ['run', scriptName], opts);
package/dist/index.d.ts CHANGED
@@ -7,13 +7,13 @@ import download, { DownloadedFiles, isSymbolicLink } from './fs/download';
7
7
  import getWriteableDirectory from './fs/get-writable-directory';
8
8
  import glob, { GlobOptions } from './fs/glob';
9
9
  import rename from './fs/rename';
10
- import { execAsync, spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, getNodeVersion, getSpawnOptions, getNodeBinPath, scanParentDirs } from './fs/run-user-scripts';
10
+ import { execAsync, spawnAsync, execCommand, spawnCommand, walkParentDirs, getScriptName, installDependencies, runPackageJsonScript, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getSpawnOptions, getNodeBinPath, scanParentDirs } from './fs/run-user-scripts';
11
11
  import { getLatestNodeVersion, getDiscontinuedNodeVersions } from './fs/node-version';
12
12
  import streamToBuffer from './fs/stream-to-buffer';
13
13
  import shouldServe from './should-serve';
14
14
  import debug from './debug';
15
15
  import getIgnoreFilter from './get-ignore-filter';
16
- export { FileBlob, FileFsRef, FileRef, Lambda, createLambda, Prerender, download, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, streamToBuffer, shouldServe, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, };
16
+ export { FileBlob, FileFsRef, FileRef, Lambda, createLambda, Prerender, download, DownloadedFiles, getWriteableDirectory, glob, GlobOptions, rename, execAsync, spawnAsync, getScriptName, installDependencies, runPackageJsonScript, execCommand, spawnCommand, walkParentDirs, getNodeBinPath, runNpmInstall, runBundleInstall, runPipInstall, runShellScript, runCustomInstallCommand, getEnvForPackageManager, getNodeVersion, getLatestNodeVersion, getDiscontinuedNodeVersions, getSpawnOptions, streamToBuffer, shouldServe, debug, isSymbolicLink, getLambdaOptionsFromFunction, scanParentDirs, getIgnoreFilter, };
17
17
  export { detectBuilders, detectOutputDirectory, detectApiDirectory, detectApiExtensions, } from './detect-builders';
18
18
  export { detectFileSystemAPI } from './detect-file-system-api';
19
19
  export { detectFramework } from './detect-framework';
package/dist/index.js CHANGED
@@ -28422,7 +28422,7 @@ exports.frameworks = [
28422
28422
  },
28423
28423
  devCommand: {
28424
28424
  placeholder: 'vite',
28425
- value: 'vite',
28425
+ value: 'vite --port $PORT',
28426
28426
  },
28427
28427
  outputDirectory: {
28428
28428
  value: 'dist',
@@ -32729,7 +32729,6 @@ const fs_extra_1 = __importDefault(__webpack_require__(5392));
32729
32729
  const path_1 = __webpack_require__(5622);
32730
32730
  const glob_1 = __importDefault(__webpack_require__(4240));
32731
32731
  const normalize_path_1 = __webpack_require__(6261);
32732
- const lambda_1 = __webpack_require__(6721);
32733
32732
  const _1 = __webpack_require__(2855);
32734
32733
  // `.output` was already created by the Build Command, so we have
32735
32734
  // to ensure its contents don't get bundled into the Lambda. Similarily,
@@ -32813,8 +32812,7 @@ function _experimental_convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32813
32812
  skipDownload: true,
32814
32813
  },
32815
32814
  });
32816
- // @ts-ignore This symbol is a private API
32817
- const lambdaFiles = output[lambda_1.FILES_SYMBOL];
32815
+ const lambdaFiles = output.files;
32818
32816
  // When deploying, the `files` that are passed to the Legacy Runtimes already
32819
32817
  // have certain files that are ignored stripped, but locally, that list of
32820
32818
  // files isn't used by the Legacy Runtimes, so we need to apply the filters
@@ -34837,7 +34835,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34837
34835
  return (mod && mod.__esModule) ? mod : { "default": mod };
34838
34836
  };
34839
34837
  Object.defineProperty(exports, "__esModule", ({ value: true }));
34840
- exports.installDependencies = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runPackageJsonScript = exports.runNpmInstall = exports.walkParentDirs = exports.scanParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.execAsync = exports.spawnAsync = void 0;
34838
+ exports.installDependencies = exports.getScriptName = exports.runPipInstall = exports.runBundleInstall = exports.runPackageJsonScript = exports.runCustomInstallCommand = exports.getEnvForPackageManager = exports.runNpmInstall = exports.walkParentDirs = exports.scanParentDirs = exports.getNodeVersion = exports.getSpawnOptions = exports.runShellScript = exports.getNodeBinPath = exports.execCommand = exports.spawnCommand = exports.execAsync = exports.spawnAsync = void 0;
34841
34839
  const assert_1 = __importDefault(__webpack_require__(2357));
34842
34840
  const fs_extra_1 = __importDefault(__webpack_require__(5392));
34843
34841
  const path_1 = __importDefault(__webpack_require__(5622));
@@ -35055,36 +35053,66 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
35055
35053
  const opts = { cwd: destPath, ...spawnOpts };
35056
35054
  const env = opts.env ? { ...opts.env } : { ...process.env };
35057
35055
  delete env.NODE_ENV;
35058
- opts.env = env;
35056
+ opts.env = getEnvForPackageManager({
35057
+ cliType,
35058
+ lockfileVersion,
35059
+ nodeVersion,
35060
+ env,
35061
+ });
35059
35062
  let commandArgs;
35060
35063
  if (cliType === 'npm') {
35061
35064
  opts.prettyCommand = 'npm install';
35062
35065
  commandArgs = args
35063
35066
  .filter(a => a !== '--prefer-offline')
35064
35067
  .concat(['install', '--no-audit', '--unsafe-perm']);
35065
- // If the lockfile version is 2 or greater and the node version is less than 16 than we will force npm7 to be used
35068
+ }
35069
+ else {
35070
+ opts.prettyCommand = 'yarn install';
35071
+ commandArgs = ['install', ...args];
35072
+ }
35073
+ if (process.env.NPM_ONLY_PRODUCTION) {
35074
+ commandArgs.push('--production');
35075
+ }
35076
+ return spawnAsync(cliType, commandArgs, opts);
35077
+ }
35078
+ exports.runNpmInstall = runNpmInstall;
35079
+ function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }) {
35080
+ const newEnv = { ...env };
35081
+ if (cliType === 'npm') {
35066
35082
  if (typeof lockfileVersion === 'number' &&
35067
35083
  lockfileVersion >= 2 &&
35068
35084
  ((nodeVersion === null || nodeVersion === void 0 ? void 0 : nodeVersion.major) || 0) < 16) {
35069
35085
  // Ensure that npm 7 is at the beginning of the `$PATH`
35070
- env.PATH = `/node16/bin-npm7:${env.PATH}`;
35086
+ newEnv.PATH = `/node16/bin-npm7:${env.PATH}`;
35071
35087
  console.log('Detected `package-lock.json` generated by npm 7...');
35072
35088
  }
35073
35089
  }
35074
35090
  else {
35075
- opts.prettyCommand = 'yarn install';
35076
- commandArgs = ['install', ...args];
35077
35091
  // Yarn v2 PnP mode may be activated, so force "node-modules" linker style
35078
35092
  if (!env.YARN_NODE_LINKER) {
35079
- env.YARN_NODE_LINKER = 'node-modules';
35093
+ newEnv.YARN_NODE_LINKER = 'node-modules';
35080
35094
  }
35081
35095
  }
35082
- if (process.env.NPM_ONLY_PRODUCTION) {
35083
- commandArgs.push('--production');
35084
- }
35085
- return spawnAsync(cliType, commandArgs, opts);
35096
+ return newEnv;
35086
35097
  }
35087
- exports.runNpmInstall = runNpmInstall;
35098
+ exports.getEnvForPackageManager = getEnvForPackageManager;
35099
+ async function runCustomInstallCommand({ destPath, installCommand, nodeVersion, spawnOpts, }) {
35100
+ console.log(`Running "install" command: \`${installCommand}\`...`);
35101
+ const { cliType, lockfileVersion } = await scanParentDirs(destPath);
35102
+ const env = getEnvForPackageManager({
35103
+ cliType,
35104
+ lockfileVersion,
35105
+ nodeVersion,
35106
+ env: (spawnOpts === null || spawnOpts === void 0 ? void 0 : spawnOpts.env) || {},
35107
+ });
35108
+ debug_1.default(`Running with $PATH:`, (env === null || env === void 0 ? void 0 : env.PATH) || '');
35109
+ await execCommand(installCommand, {
35110
+ ...spawnOpts,
35111
+ env,
35112
+ cwd: destPath,
35113
+ });
35114
+ }
35115
+ exports.runCustomInstallCommand = runCustomInstallCommand;
35088
35116
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
35089
35117
  assert_1.default(path_1.default.isAbsolute(destPath));
35090
35118
  const { packageJson, cliType, lockfileVersion } = await scanParentDirs(destPath, true);
@@ -35093,21 +35121,24 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
35093
35121
  return false;
35094
35122
  debug_1.default('Running user script...');
35095
35123
  const runScriptTime = Date.now();
35096
- const opts = { cwd: destPath, ...spawnOpts };
35097
- const env = (opts.env = { ...process.env, ...opts.env });
35124
+ const opts = {
35125
+ cwd: destPath,
35126
+ ...spawnOpts,
35127
+ env: getEnvForPackageManager({
35128
+ cliType,
35129
+ lockfileVersion,
35130
+ nodeVersion: undefined,
35131
+ env: {
35132
+ ...process.env,
35133
+ ...spawnOpts === null || spawnOpts === void 0 ? void 0 : spawnOpts.env,
35134
+ },
35135
+ }),
35136
+ };
35098
35137
  if (cliType === 'npm') {
35099
35138
  opts.prettyCommand = `npm run ${scriptName}`;
35100
- if (typeof lockfileVersion === 'number' && lockfileVersion >= 2) {
35101
- // Ensure that npm 7 is at the beginning of the `$PATH`
35102
- env.PATH = `/node16/bin-npm7:${env.PATH}`;
35103
- }
35104
35139
  }
35105
35140
  else {
35106
35141
  opts.prettyCommand = `yarn run ${scriptName}`;
35107
- // Yarn v2 PnP mode may be activated, so force "node-modules" linker style
35108
- if (!env.YARN_NODE_LINKER) {
35109
- env.YARN_NODE_LINKER = 'node-modules';
35110
- }
35111
35142
  }
35112
35143
  console.log(`Running "${opts.prettyCommand}"`);
35113
35144
  await spawnAsync(cliType, ['run', scriptName], opts);
@@ -35290,7 +35321,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35290
35321
  return (mod && mod.__esModule) ? mod : { "default": mod };
35291
35322
  };
35292
35323
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35293
- exports.getPlatformEnv = exports.isStaticRuntime = exports.isOfficialRuntime = exports._experimental_updateRoutesManifest = exports._experimental_updateFunctionsManifest = exports._experimental_convertRuntimeToPlugin = exports.normalizePath = exports.readConfigFile = exports.DetectorFilesystem = exports.detectFramework = exports.detectFileSystemAPI = exports.detectApiExtensions = exports.detectApiDirectory = exports.detectOutputDirectory = exports.detectBuilders = exports.getIgnoreFilter = 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;
35324
+ exports.isStaticRuntime = exports.isOfficialRuntime = exports._experimental_updateRoutesManifest = exports._experimental_updateFunctionsManifest = exports._experimental_convertRuntimeToPlugin = exports.normalizePath = exports.readConfigFile = exports.DetectorFilesystem = exports.detectFramework = exports.detectFileSystemAPI = exports.detectApiExtensions = exports.detectApiDirectory = exports.detectOutputDirectory = exports.detectBuilders = exports.getIgnoreFilter = exports.scanParentDirs = exports.getLambdaOptionsFromFunction = exports.isSymbolicLink = exports.debug = exports.shouldServe = exports.streamToBuffer = exports.getSpawnOptions = exports.getDiscontinuedNodeVersions = exports.getLatestNodeVersion = exports.getNodeVersion = exports.getEnvForPackageManager = exports.runCustomInstallCommand = 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;
35325
+ exports.getPlatformEnv = void 0;
35294
35326
  const file_blob_1 = __importDefault(__webpack_require__(2397));
35295
35327
  exports.FileBlob = file_blob_1.default;
35296
35328
  const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
@@ -35325,6 +35357,8 @@ Object.defineProperty(exports, "runNpmInstall", ({ enumerable: true, get: functi
35325
35357
  Object.defineProperty(exports, "runBundleInstall", ({ enumerable: true, get: function () { return run_user_scripts_1.runBundleInstall; } }));
35326
35358
  Object.defineProperty(exports, "runPipInstall", ({ enumerable: true, get: function () { return run_user_scripts_1.runPipInstall; } }));
35327
35359
  Object.defineProperty(exports, "runShellScript", ({ enumerable: true, get: function () { return run_user_scripts_1.runShellScript; } }));
35360
+ Object.defineProperty(exports, "runCustomInstallCommand", ({ enumerable: true, get: function () { return run_user_scripts_1.runCustomInstallCommand; } }));
35361
+ Object.defineProperty(exports, "getEnvForPackageManager", ({ enumerable: true, get: function () { return run_user_scripts_1.getEnvForPackageManager; } }));
35328
35362
  Object.defineProperty(exports, "getNodeVersion", ({ enumerable: true, get: function () { return run_user_scripts_1.getNodeVersion; } }));
35329
35363
  Object.defineProperty(exports, "getSpawnOptions", ({ enumerable: true, get: function () { return run_user_scripts_1.getSpawnOptions; } }));
35330
35364
  Object.defineProperty(exports, "getNodeBinPath", ({ enumerable: true, get: function () { return run_user_scripts_1.getNodeBinPath; } }));
@@ -35415,7 +35449,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35415
35449
  return (mod && mod.__esModule) ? mod : { "default": mod };
35416
35450
  };
35417
35451
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35418
- exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = exports.FILES_SYMBOL = void 0;
35452
+ exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = void 0;
35419
35453
  const assert_1 = __importDefault(__webpack_require__(2357));
35420
35454
  const async_sema_1 = __importDefault(__webpack_require__(5758));
35421
35455
  const yazl_1 = __webpack_require__(1223);
@@ -35423,11 +35457,28 @@ const minimatch_1 = __importDefault(__webpack_require__(9566));
35423
35457
  const fs_extra_1 = __webpack_require__(5392);
35424
35458
  const download_1 = __webpack_require__(1611);
35425
35459
  const stream_to_buffer_1 = __importDefault(__webpack_require__(2560));
35426
- exports.FILES_SYMBOL = Symbol('files');
35427
35460
  class Lambda {
35428
- constructor({ zipBuffer, handler, runtime, maxDuration, memory, environment, allowQuery, regions, }) {
35461
+ constructor({ files, handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, }) {
35462
+ assert_1.default(typeof files === 'object', '"files" must be an object');
35463
+ assert_1.default(typeof handler === 'string', '"handler" is not a string');
35464
+ assert_1.default(typeof runtime === 'string', '"runtime" is not a string');
35465
+ assert_1.default(typeof environment === 'object', '"environment" is not an object');
35466
+ if (memory !== undefined) {
35467
+ assert_1.default(typeof memory === 'number', '"memory" is not a number');
35468
+ }
35469
+ if (maxDuration !== undefined) {
35470
+ assert_1.default(typeof maxDuration === 'number', '"maxDuration" is not a number');
35471
+ }
35472
+ if (allowQuery !== undefined) {
35473
+ assert_1.default(Array.isArray(allowQuery), '"allowQuery" is not an Array');
35474
+ assert_1.default(allowQuery.every(q => typeof q === 'string'), '"allowQuery" is not a string Array');
35475
+ }
35476
+ if (regions !== undefined) {
35477
+ assert_1.default(Array.isArray(regions), '"regions" is not an Array');
35478
+ assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
35479
+ }
35429
35480
  this.type = 'Lambda';
35430
- this.zipBuffer = zipBuffer;
35481
+ this.files = files;
35431
35482
  this.handler = handler;
35432
35483
  this.runtime = runtime;
35433
35484
  this.memory = memory;
@@ -35436,48 +35487,31 @@ class Lambda {
35436
35487
  this.allowQuery = allowQuery;
35437
35488
  this.regions = regions;
35438
35489
  }
35490
+ async createZip() {
35491
+ let { zipBuffer } = this;
35492
+ if (!zipBuffer) {
35493
+ await sema.acquire();
35494
+ try {
35495
+ zipBuffer = await createZip(this.files);
35496
+ }
35497
+ finally {
35498
+ sema.release();
35499
+ }
35500
+ }
35501
+ return zipBuffer;
35502
+ }
35439
35503
  }
35440
35504
  exports.Lambda = Lambda;
35441
35505
  const sema = new async_sema_1.default(10);
35442
35506
  const mtime = new Date(1540000000000);
35443
- async function createLambda({ files, handler, runtime, memory, maxDuration, environment = {}, allowQuery, regions, }) {
35444
- assert_1.default(typeof files === 'object', '"files" must be an object');
35445
- assert_1.default(typeof handler === 'string', '"handler" is not a string');
35446
- assert_1.default(typeof runtime === 'string', '"runtime" is not a string');
35447
- assert_1.default(typeof environment === 'object', '"environment" is not an object');
35448
- if (memory !== undefined) {
35449
- assert_1.default(typeof memory === 'number', '"memory" is not a number');
35450
- }
35451
- if (maxDuration !== undefined) {
35452
- assert_1.default(typeof maxDuration === 'number', '"maxDuration" is not a number');
35453
- }
35454
- if (allowQuery !== undefined) {
35455
- assert_1.default(Array.isArray(allowQuery), '"allowQuery" is not an Array');
35456
- assert_1.default(allowQuery.every(q => typeof q === 'string'), '"allowQuery" is not a string Array');
35457
- }
35458
- if (regions !== undefined) {
35459
- assert_1.default(Array.isArray(regions), '"regions" is not an Array');
35460
- assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
35461
- }
35462
- await sema.acquire();
35463
- try {
35464
- const zipBuffer = await createZip(files);
35465
- const lambda = new Lambda({
35466
- zipBuffer,
35467
- handler,
35468
- runtime,
35469
- memory,
35470
- maxDuration,
35471
- environment,
35472
- regions,
35473
- });
35474
- // @ts-ignore This symbol is a private API
35475
- lambda[exports.FILES_SYMBOL] = files;
35476
- return lambda;
35477
- }
35478
- finally {
35479
- sema.release();
35480
- }
35507
+ /**
35508
+ * @deprecated Use `new Lambda()` instead.
35509
+ */
35510
+ async function createLambda(opts) {
35511
+ const lambda = new Lambda(opts);
35512
+ // backwards compat
35513
+ lambda.zipBuffer = await lambda.createZip();
35514
+ return lambda;
35481
35515
  }
35482
35516
  exports.createLambda = createLambda;
35483
35517
  async function createZip(files) {
@@ -35512,7 +35546,7 @@ async function createZip(files) {
35512
35546
  }
35513
35547
  exports.createZip = createZip;
35514
35548
  async function getLambdaOptionsFromFunction({ sourceFile, config, }) {
35515
- if (config && config.functions) {
35549
+ if (config === null || config === void 0 ? void 0 : config.functions) {
35516
35550
  for (const [pattern, fn] of Object.entries(config.functions)) {
35517
35551
  if (sourceFile === pattern || minimatch_1.default(sourceFile, pattern)) {
35518
35552
  return {
package/dist/lambda.d.ts CHANGED
@@ -4,16 +4,6 @@ interface Environment {
4
4
  [key: string]: string;
5
5
  }
6
6
  interface LambdaOptions {
7
- zipBuffer: Buffer;
8
- handler: string;
9
- runtime: string;
10
- memory?: number;
11
- maxDuration?: number;
12
- environment: Environment;
13
- allowQuery?: string[];
14
- regions?: string[];
15
- }
16
- interface CreateLambdaOptions {
17
7
  files: Files;
18
8
  handler: string;
19
9
  runtime: string;
@@ -27,10 +17,9 @@ interface GetLambdaOptionsFromFunctionOptions {
27
17
  sourceFile: string;
28
18
  config?: Pick<Config, 'functions'>;
29
19
  }
30
- export declare const FILES_SYMBOL: unique symbol;
31
20
  export declare class Lambda {
32
21
  type: 'Lambda';
33
- zipBuffer: Buffer;
22
+ files: Files;
34
23
  handler: string;
35
24
  runtime: string;
36
25
  memory?: number;
@@ -38,9 +27,17 @@ export declare class Lambda {
38
27
  environment: Environment;
39
28
  allowQuery?: string[];
40
29
  regions?: string[];
41
- constructor({ zipBuffer, handler, runtime, maxDuration, memory, environment, allowQuery, regions, }: LambdaOptions);
30
+ /**
31
+ * @deprecated Use `await lambda.createZip()` instead.
32
+ */
33
+ zipBuffer?: Buffer;
34
+ constructor({ files, handler, runtime, maxDuration, memory, environment, allowQuery, regions, }: LambdaOptions);
35
+ createZip(): Promise<Buffer>;
42
36
  }
43
- export declare function createLambda({ files, handler, runtime, memory, maxDuration, environment, allowQuery, regions, }: CreateLambdaOptions): Promise<Lambda>;
37
+ /**
38
+ * @deprecated Use `new Lambda()` instead.
39
+ */
40
+ export declare function createLambda(opts: LambdaOptions): Promise<Lambda>;
44
41
  export declare function createZip(files: Files): Promise<Buffer>;
45
42
  export declare function getLambdaOptionsFromFunction({ sourceFile, config, }: GetLambdaOptionsFromFunctionOptions): Promise<Pick<LambdaOptions, 'memory' | 'maxDuration'>>;
46
43
  export {};
package/dist/lambda.js CHANGED
@@ -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.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = exports.FILES_SYMBOL = void 0;
6
+ exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = void 0;
7
7
  const assert_1 = __importDefault(require("assert"));
8
8
  const async_sema_1 = __importDefault(require("async-sema"));
9
9
  const yazl_1 = require("yazl");
@@ -11,11 +11,28 @@ const minimatch_1 = __importDefault(require("minimatch"));
11
11
  const fs_extra_1 = require("fs-extra");
12
12
  const download_1 = require("./fs/download");
13
13
  const stream_to_buffer_1 = __importDefault(require("./fs/stream-to-buffer"));
14
- exports.FILES_SYMBOL = Symbol('files');
15
14
  class Lambda {
16
- constructor({ zipBuffer, handler, runtime, maxDuration, memory, environment, allowQuery, regions, }) {
15
+ constructor({ files, handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, }) {
16
+ assert_1.default(typeof files === 'object', '"files" must be an object');
17
+ assert_1.default(typeof handler === 'string', '"handler" is not a string');
18
+ assert_1.default(typeof runtime === 'string', '"runtime" is not a string');
19
+ assert_1.default(typeof environment === 'object', '"environment" is not an object');
20
+ if (memory !== undefined) {
21
+ assert_1.default(typeof memory === 'number', '"memory" is not a number');
22
+ }
23
+ if (maxDuration !== undefined) {
24
+ assert_1.default(typeof maxDuration === 'number', '"maxDuration" is not a number');
25
+ }
26
+ if (allowQuery !== undefined) {
27
+ assert_1.default(Array.isArray(allowQuery), '"allowQuery" is not an Array');
28
+ assert_1.default(allowQuery.every(q => typeof q === 'string'), '"allowQuery" is not a string Array');
29
+ }
30
+ if (regions !== undefined) {
31
+ assert_1.default(Array.isArray(regions), '"regions" is not an Array');
32
+ assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
33
+ }
17
34
  this.type = 'Lambda';
18
- this.zipBuffer = zipBuffer;
35
+ this.files = files;
19
36
  this.handler = handler;
20
37
  this.runtime = runtime;
21
38
  this.memory = memory;
@@ -24,48 +41,31 @@ class Lambda {
24
41
  this.allowQuery = allowQuery;
25
42
  this.regions = regions;
26
43
  }
44
+ async createZip() {
45
+ let { zipBuffer } = this;
46
+ if (!zipBuffer) {
47
+ await sema.acquire();
48
+ try {
49
+ zipBuffer = await createZip(this.files);
50
+ }
51
+ finally {
52
+ sema.release();
53
+ }
54
+ }
55
+ return zipBuffer;
56
+ }
27
57
  }
28
58
  exports.Lambda = Lambda;
29
59
  const sema = new async_sema_1.default(10);
30
60
  const mtime = new Date(1540000000000);
31
- async function createLambda({ files, handler, runtime, memory, maxDuration, environment = {}, allowQuery, regions, }) {
32
- assert_1.default(typeof files === 'object', '"files" must be an object');
33
- assert_1.default(typeof handler === 'string', '"handler" is not a string');
34
- assert_1.default(typeof runtime === 'string', '"runtime" is not a string');
35
- assert_1.default(typeof environment === 'object', '"environment" is not an object');
36
- if (memory !== undefined) {
37
- assert_1.default(typeof memory === 'number', '"memory" is not a number');
38
- }
39
- if (maxDuration !== undefined) {
40
- assert_1.default(typeof maxDuration === 'number', '"maxDuration" is not a number');
41
- }
42
- if (allowQuery !== undefined) {
43
- assert_1.default(Array.isArray(allowQuery), '"allowQuery" is not an Array');
44
- assert_1.default(allowQuery.every(q => typeof q === 'string'), '"allowQuery" is not a string Array');
45
- }
46
- if (regions !== undefined) {
47
- assert_1.default(Array.isArray(regions), '"regions" is not an Array');
48
- assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
49
- }
50
- await sema.acquire();
51
- try {
52
- const zipBuffer = await createZip(files);
53
- const lambda = new Lambda({
54
- zipBuffer,
55
- handler,
56
- runtime,
57
- memory,
58
- maxDuration,
59
- environment,
60
- regions,
61
- });
62
- // @ts-ignore This symbol is a private API
63
- lambda[exports.FILES_SYMBOL] = files;
64
- return lambda;
65
- }
66
- finally {
67
- sema.release();
68
- }
61
+ /**
62
+ * @deprecated Use `new Lambda()` instead.
63
+ */
64
+ async function createLambda(opts) {
65
+ const lambda = new Lambda(opts);
66
+ // backwards compat
67
+ lambda.zipBuffer = await lambda.createZip();
68
+ return lambda;
69
69
  }
70
70
  exports.createLambda = createLambda;
71
71
  async function createZip(files) {
@@ -100,7 +100,7 @@ async function createZip(files) {
100
100
  }
101
101
  exports.createZip = createZip;
102
102
  async function getLambdaOptionsFromFunction({ sourceFile, config, }) {
103
- if (config && config.functions) {
103
+ if (config === null || config === void 0 ? void 0 : config.functions) {
104
104
  for (const [pattern, fn] of Object.entries(config.functions)) {
105
105
  if (sourceFile === pattern || minimatch_1.default(sourceFile, pattern)) {
106
106
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.13.1-canary.0",
3
+ "version": "2.13.1-canary.1",
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.20",
33
+ "@vercel/frameworks": "0.5.1-canary.21",
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": "9bbb2cdcbd39846f4a7c97c3cf8838eee130eec4"
52
+ "gitHead": "ab1decf79da76e85f7f562d1c4ee5e5dcf4c2a17"
53
53
  }