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

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/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',
@@ -28485,6 +28485,49 @@ exports.frameworks = [
28485
28485
  },
28486
28486
  ],
28487
28487
  },
28488
+ {
28489
+ name: 'Sanity',
28490
+ slug: 'sanity',
28491
+ demo: 'https://sanity-studio-template.vercel.app',
28492
+ logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/sanity.svg',
28493
+ tagline: 'The structured content platform.',
28494
+ description: 'A Sanity Studio',
28495
+ website: 'https://www.sanity.io',
28496
+ envPrefix: 'SANITY_STUDIO_',
28497
+ detectors: {
28498
+ every: [
28499
+ {
28500
+ path: 'sanity.json',
28501
+ },
28502
+ ],
28503
+ },
28504
+ settings: {
28505
+ installCommand: {
28506
+ placeholder: '`yarn install` or `npm install`',
28507
+ },
28508
+ buildCommand: {
28509
+ placeholder: '`npm run build` or `sanity build`',
28510
+ value: 'sanity build',
28511
+ },
28512
+ devCommand: {
28513
+ value: 'sanity start --port $PORT',
28514
+ },
28515
+ outputDirectory: {
28516
+ value: 'dist',
28517
+ },
28518
+ },
28519
+ dependency: '@sanity/cli',
28520
+ getOutputDirName: async () => 'dist',
28521
+ defaultRoutes: [
28522
+ {
28523
+ handle: 'filesystem',
28524
+ },
28525
+ {
28526
+ src: '/(.*)',
28527
+ dest: '/index.html',
28528
+ },
28529
+ ],
28530
+ },
28488
28531
  {
28489
28532
  name: 'Other',
28490
28533
  slug: null,
@@ -32713,312 +32756,6 @@ module.exports = new Type('tag:yaml.org,2002:timestamp', {
32713
32756
  });
32714
32757
 
32715
32758
 
32716
- /***/ }),
32717
-
32718
- /***/ 7276:
32719
- /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
32720
-
32721
- "use strict";
32722
-
32723
- var __importDefault = (this && this.__importDefault) || function (mod) {
32724
- return (mod && mod.__esModule) ? mod : { "default": mod };
32725
- };
32726
- Object.defineProperty(exports, "__esModule", ({ value: true }));
32727
- exports._experimental_updateRoutesManifest = exports._experimental_updateFunctionsManifest = exports._experimental_convertRuntimeToPlugin = void 0;
32728
- const fs_extra_1 = __importDefault(__webpack_require__(5392));
32729
- const path_1 = __webpack_require__(5622);
32730
- const glob_1 = __importDefault(__webpack_require__(4240));
32731
- const normalize_path_1 = __webpack_require__(6261);
32732
- const lambda_1 = __webpack_require__(6721);
32733
- const _1 = __webpack_require__(2855);
32734
- // `.output` was already created by the Build Command, so we have
32735
- // to ensure its contents don't get bundled into the Lambda. Similarily,
32736
- // we don't want to bundle anything from `.vercel` either. Lastly,
32737
- // Builders/Runtimes didn't have `vercel.json` or `now.json`.
32738
- const ignoredPaths = ['.output', '.vercel', 'vercel.json', 'now.json'];
32739
- const shouldIgnorePath = (file, ignoreFilter, ignoreFile) => {
32740
- const isNative = ignoredPaths.some(item => {
32741
- return file.startsWith(item);
32742
- });
32743
- if (!ignoreFile) {
32744
- return isNative;
32745
- }
32746
- return isNative || ignoreFilter(file);
32747
- };
32748
- const getSourceFiles = async (workPath, ignoreFilter) => {
32749
- const list = await glob_1.default('**', {
32750
- cwd: workPath,
32751
- });
32752
- // We're not passing this as an `ignore` filter to the `glob` function above,
32753
- // so that we can re-use exactly the same `getIgnoreFilter` method that the
32754
- // Build Step uses (literally the same code). Note that this exclusion only applies
32755
- // when deploying. Locally, another exclusion is needed, which is handled
32756
- // further below in the `convertRuntimeToPlugin` function.
32757
- for (const file in list) {
32758
- if (shouldIgnorePath(file, ignoreFilter, true)) {
32759
- delete list[file];
32760
- }
32761
- }
32762
- return list;
32763
- };
32764
- /**
32765
- * Convert legacy Runtime to a Plugin.
32766
- * @param buildRuntime - a legacy build() function from a Runtime
32767
- * @param packageName - the name of the package, for example `vercel-plugin-python`
32768
- * @param ext - the file extension, for example `.py`
32769
- */
32770
- function _experimental_convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32771
- // This `build()` signature should match `plugin.build()` signature in `vercel build`.
32772
- return async function build({ workPath }) {
32773
- // We also don't want to provide any files to Runtimes that were ignored
32774
- // through `.vercelignore` or `.nowignore`, because the Build Step does the same.
32775
- const ignoreFilter = await _1.getIgnoreFilter(workPath);
32776
- // Retrieve the files that are currently available on the File System,
32777
- // before the Legacy Runtime has even started to build.
32778
- const sourceFilesPreBuild = await getSourceFiles(workPath, ignoreFilter);
32779
- // Instead of doing another `glob` to get all the matching source files,
32780
- // we'll filter the list of existing files down to only the ones
32781
- // that are matching the entrypoint pattern, so we're first creating
32782
- // a clean new list to begin.
32783
- const entrypoints = Object.assign({}, sourceFilesPreBuild);
32784
- const entrypointMatch = new RegExp(`^api/.*${ext}$`);
32785
- // Up next, we'll strip out the files from the list of entrypoints
32786
- // that aren't actually considered entrypoints.
32787
- for (const file in entrypoints) {
32788
- if (!entrypointMatch.test(file)) {
32789
- delete entrypoints[file];
32790
- }
32791
- }
32792
- const pages = {};
32793
- const pluginName = packageName.replace('vercel-plugin-', '');
32794
- const outputPath = path_1.join(workPath, '.output');
32795
- const traceDir = path_1.join(outputPath, `inputs`,
32796
- // Legacy Runtimes can only provide API Routes, so that's
32797
- // why we can use this prefix for all of them. Here, we have to
32798
- // make sure to not use a cryptic hash name, because people
32799
- // need to be able to easily inspect the output.
32800
- `api-routes-${pluginName}`);
32801
- await fs_extra_1.default.ensureDir(traceDir);
32802
- const entryRoot = path_1.join(outputPath, 'server', 'pages');
32803
- for (const entrypoint of Object.keys(entrypoints)) {
32804
- const { output } = await buildRuntime({
32805
- files: sourceFilesPreBuild,
32806
- entrypoint,
32807
- workPath,
32808
- config: {
32809
- zeroConfig: true,
32810
- },
32811
- meta: {
32812
- avoidTopLevelInstall: true,
32813
- skipDownload: true,
32814
- },
32815
- });
32816
- // @ts-ignore This symbol is a private API
32817
- const lambdaFiles = output[lambda_1.FILES_SYMBOL];
32818
- // When deploying, the `files` that are passed to the Legacy Runtimes already
32819
- // have certain files that are ignored stripped, but locally, that list of
32820
- // files isn't used by the Legacy Runtimes, so we need to apply the filters
32821
- // to the outputs that they are returning instead.
32822
- for (const file in lambdaFiles) {
32823
- if (shouldIgnorePath(file, ignoreFilter, false)) {
32824
- delete lambdaFiles[file];
32825
- }
32826
- }
32827
- let handlerFileBase = output.handler;
32828
- let handlerFile = lambdaFiles[handlerFileBase];
32829
- let handlerHasImport = false;
32830
- const { handler } = output;
32831
- const handlerMethod = handler.split('.').pop();
32832
- const handlerFileName = handler.replace(`.${handlerMethod}`, '');
32833
- // For compiled languages, the launcher file for the Lambda generated
32834
- // by the Legacy Runtime matches the `handler` defined for it, but for
32835
- // interpreted languages, the `handler` consists of the launcher file name
32836
- // without an extension, plus the name of the method inside of that file
32837
- // that should be invoked, so we have to construct the file path explicitly.
32838
- if (!handlerFile) {
32839
- handlerFileBase = handlerFileName + ext;
32840
- handlerFile = lambdaFiles[handlerFileBase];
32841
- handlerHasImport = true;
32842
- }
32843
- if (!handlerFile || !handlerFile.fsPath) {
32844
- throw new Error(`Could not find a handler file. Please ensure that \`files\` for the returned \`Lambda\` contains an \`FileFsRef\` named "${handlerFileBase}" with a valid \`fsPath\`.`);
32845
- }
32846
- const handlerExtName = path_1.extname(handlerFile.fsPath);
32847
- const entryBase = path_1.basename(entrypoint).replace(ext, handlerExtName);
32848
- const entryPath = path_1.join(path_1.dirname(entrypoint), entryBase);
32849
- const entry = path_1.join(entryRoot, entryPath);
32850
- // Create the parent directory of the API Route that will be created
32851
- // for the current entrypoint inside of `.output/server/pages/api`.
32852
- await fs_extra_1.default.ensureDir(path_1.dirname(entry));
32853
- // For compiled languages, the launcher file will be binary and therefore
32854
- // won't try to import a user-provided request handler (instead, it will
32855
- // contain it). But for interpreted languages, the launcher might try to
32856
- // load a user-provided request handler from the source file instead of bundling
32857
- // it, so we have to adjust the import statement inside the launcher to point
32858
- // to the respective source file. Previously, Legacy Runtimes simply expected
32859
- // the user-provided request-handler to be copied right next to the launcher,
32860
- // but with the new File System API, files won't be moved around unnecessarily.
32861
- if (handlerHasImport) {
32862
- const { fsPath } = handlerFile;
32863
- const encoding = 'utf-8';
32864
- // This is the true directory of the user-provided request handler in the
32865
- // source files, so that's what we will use as an import path in the launcher.
32866
- const locationPrefix = path_1.relative(entry, outputPath);
32867
- let handlerContent = await fs_extra_1.default.readFile(fsPath, encoding);
32868
- const importPaths = [
32869
- // This is the full entrypoint path, like `./api/test.py`. In our tests
32870
- // Python didn't support importing from a parent directory without using different
32871
- // code in the launcher that registers it as a location for modules and then changing
32872
- // the importing syntax, but continuing to import it like before seems to work. If
32873
- // other languages need this, we should consider excluding Python explicitly.
32874
- // `./${entrypoint}`,
32875
- // This is the entrypoint path without extension, like `api/test`
32876
- entrypoint.slice(0, -ext.length),
32877
- ];
32878
- // Generate a list of regular expressions that we can use for
32879
- // finding matches, but only allow matches if the import path is
32880
- // wrapped inside single (') or double quotes (").
32881
- const patterns = importPaths.map(path => {
32882
- // eslint-disable-next-line no-useless-escape
32883
- return new RegExp(`('|")(${path.replace(/\./g, '\\.')})('|")`, 'g');
32884
- });
32885
- let replacedMatch = null;
32886
- for (const pattern of patterns) {
32887
- const newContent = handlerContent.replace(pattern, (_, p1, p2, p3) => {
32888
- return `${p1}${path_1.join(locationPrefix, p2)}${p3}`;
32889
- });
32890
- if (newContent !== handlerContent) {
32891
- _1.debug(`Replaced "${pattern}" inside "${entry}" to ensure correct import of user-provided request handler`);
32892
- handlerContent = newContent;
32893
- replacedMatch = true;
32894
- }
32895
- }
32896
- if (!replacedMatch) {
32897
- new Error(`No replacable matches for "${importPaths[0]}" or "${importPaths[1]}" found in "${fsPath}"`);
32898
- }
32899
- await fs_extra_1.default.writeFile(entry, handlerContent, encoding);
32900
- }
32901
- else {
32902
- await fs_extra_1.default.copy(handlerFile.fsPath, entry);
32903
- }
32904
- // Legacy Runtimes based on interpreted languages will create a new launcher file
32905
- // for every entrypoint, but they will create each one inside `workPath`, which means that
32906
- // the launcher for one entrypoint will overwrite the launcher provided for the previous
32907
- // entrypoint. That's why, above, we copy the file contents into the new destination (and
32908
- // optionally transform them along the way), instead of linking. We then also want to remove
32909
- // the copy origin right here, so that the `workPath` doesn't contain a useless launcher file
32910
- // once the build has finished running.
32911
- await fs_extra_1.default.remove(handlerFile.fsPath);
32912
- _1.debug(`Removed temporary file "${handlerFile.fsPath}"`);
32913
- const nft = `${entry}.nft.json`;
32914
- const json = JSON.stringify({
32915
- version: 2,
32916
- files: Object.keys(lambdaFiles)
32917
- .map(file => {
32918
- const { fsPath } = lambdaFiles[file];
32919
- if (!fsPath) {
32920
- throw new Error(`File "${file}" is missing valid \`fsPath\` property`);
32921
- }
32922
- // The handler was already moved into position above.
32923
- if (file === handlerFileBase) {
32924
- return;
32925
- }
32926
- return normalize_path_1.normalizePath(path_1.relative(path_1.dirname(nft), fsPath));
32927
- })
32928
- .filter(Boolean),
32929
- });
32930
- await fs_extra_1.default.writeFile(nft, json);
32931
- // Add an entry that will later on be added to the `functions-manifest.json`
32932
- // file that is placed inside of the `.output` directory.
32933
- pages[normalize_path_1.normalizePath(entryPath)] = {
32934
- // Because the underlying file used as a handler was placed
32935
- // inside `.output/server/pages/api`, it no longer has the name it originally
32936
- // had and is now named after the API Route that it's responsible for,
32937
- // so we have to adjust the name of the Lambda handler accordingly.
32938
- handler: handler.replace(handlerFileName, path_1.parse(entry).name),
32939
- runtime: output.runtime,
32940
- memory: output.memory,
32941
- maxDuration: output.maxDuration,
32942
- environment: output.environment,
32943
- allowQuery: output.allowQuery,
32944
- };
32945
- }
32946
- // Add any Serverless Functions that were exposed by the Legacy Runtime
32947
- // to the `functions-manifest.json` file provided in `.output`.
32948
- await _experimental_updateFunctionsManifest({ workPath, pages });
32949
- };
32950
- }
32951
- exports._experimental_convertRuntimeToPlugin = _experimental_convertRuntimeToPlugin;
32952
- async function readJson(filePath) {
32953
- try {
32954
- const str = await fs_extra_1.default.readFile(filePath, 'utf8');
32955
- return JSON.parse(str);
32956
- }
32957
- catch (err) {
32958
- if (err.code === 'ENOENT') {
32959
- return {};
32960
- }
32961
- throw err;
32962
- }
32963
- }
32964
- /**
32965
- * If `.output/functions-manifest.json` exists, append to the pages
32966
- * property. Otherwise write a new file.
32967
- */
32968
- async function _experimental_updateFunctionsManifest({ workPath, pages, }) {
32969
- const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
32970
- const functionsManifest = await readJson(functionsManifestPath);
32971
- if (!functionsManifest.version)
32972
- functionsManifest.version = 2;
32973
- if (!functionsManifest.pages)
32974
- functionsManifest.pages = {};
32975
- for (const [pageKey, pageConfig] of Object.entries(pages)) {
32976
- functionsManifest.pages[pageKey] = { ...pageConfig };
32977
- }
32978
- await fs_extra_1.default.writeFile(functionsManifestPath, JSON.stringify(functionsManifest));
32979
- }
32980
- exports._experimental_updateFunctionsManifest = _experimental_updateFunctionsManifest;
32981
- /**
32982
- * Append routes to the `routes-manifest.json` file.
32983
- * If the file does not exist, it will be created.
32984
- */
32985
- async function _experimental_updateRoutesManifest({ workPath, redirects, rewrites, headers, dynamicRoutes, staticRoutes, }) {
32986
- const routesManifestPath = path_1.join(workPath, '.output', 'routes-manifest.json');
32987
- const routesManifest = await readJson(routesManifestPath);
32988
- if (!routesManifest.version)
32989
- routesManifest.version = 3;
32990
- if (routesManifest.pages404 === undefined)
32991
- routesManifest.pages404 = true;
32992
- if (redirects) {
32993
- if (!routesManifest.redirects)
32994
- routesManifest.redirects = [];
32995
- routesManifest.redirects.push(...redirects);
32996
- }
32997
- if (rewrites) {
32998
- if (!routesManifest.rewrites)
32999
- routesManifest.rewrites = [];
33000
- routesManifest.rewrites.push(...rewrites);
33001
- }
33002
- if (headers) {
33003
- if (!routesManifest.headers)
33004
- routesManifest.headers = [];
33005
- routesManifest.headers.push(...headers);
33006
- }
33007
- if (dynamicRoutes) {
33008
- if (!routesManifest.dynamicRoutes)
33009
- routesManifest.dynamicRoutes = [];
33010
- routesManifest.dynamicRoutes.push(...dynamicRoutes);
33011
- }
33012
- if (staticRoutes) {
33013
- if (!routesManifest.staticRoutes)
33014
- routesManifest.staticRoutes = [];
33015
- routesManifest.staticRoutes.push(...staticRoutes);
33016
- }
33017
- await fs_extra_1.default.writeFile(routesManifestPath, JSON.stringify(routesManifest));
33018
- }
33019
- exports._experimental_updateRoutesManifest = _experimental_updateRoutesManifest;
33020
-
33021
-
33022
32759
  /***/ }),
33023
32760
 
33024
32761
  /***/ 1868:
@@ -33027,9 +32764,9 @@ exports._experimental_updateRoutesManifest = _experimental_updateRoutesManifest;
33027
32764
  "use strict";
33028
32765
 
33029
32766
  Object.defineProperty(exports, "__esModule", ({ value: true }));
33030
- const _1 = __webpack_require__(2855);
32767
+ const get_platform_env_1 = __webpack_require__(4678);
33031
32768
  function debug(message, ...additional) {
33032
- if (_1.getPlatformEnv('BUILDER_DEBUG')) {
32769
+ if (get_platform_env_1.getPlatformEnv('BUILDER_DEBUG')) {
33033
32770
  console.log(message, ...additional);
33034
32771
  }
33035
32772
  }
@@ -34837,7 +34574,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34837
34574
  return (mod && mod.__esModule) ? mod : { "default": mod };
34838
34575
  };
34839
34576
  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;
34577
+ 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
34578
  const assert_1 = __importDefault(__webpack_require__(2357));
34842
34579
  const fs_extra_1 = __importDefault(__webpack_require__(5392));
34843
34580
  const path_1 = __importDefault(__webpack_require__(5622));
@@ -35055,36 +34792,66 @@ async function runNpmInstall(destPath, args = [], spawnOpts, meta, nodeVersion)
35055
34792
  const opts = { cwd: destPath, ...spawnOpts };
35056
34793
  const env = opts.env ? { ...opts.env } : { ...process.env };
35057
34794
  delete env.NODE_ENV;
35058
- opts.env = env;
34795
+ opts.env = getEnvForPackageManager({
34796
+ cliType,
34797
+ lockfileVersion,
34798
+ nodeVersion,
34799
+ env,
34800
+ });
35059
34801
  let commandArgs;
35060
34802
  if (cliType === 'npm') {
35061
34803
  opts.prettyCommand = 'npm install';
35062
34804
  commandArgs = args
35063
34805
  .filter(a => a !== '--prefer-offline')
35064
34806
  .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
34807
+ }
34808
+ else {
34809
+ opts.prettyCommand = 'yarn install';
34810
+ commandArgs = ['install', ...args];
34811
+ }
34812
+ if (process.env.NPM_ONLY_PRODUCTION) {
34813
+ commandArgs.push('--production');
34814
+ }
34815
+ return spawnAsync(cliType, commandArgs, opts);
34816
+ }
34817
+ exports.runNpmInstall = runNpmInstall;
34818
+ function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }) {
34819
+ const newEnv = { ...env };
34820
+ if (cliType === 'npm') {
35066
34821
  if (typeof lockfileVersion === 'number' &&
35067
34822
  lockfileVersion >= 2 &&
35068
34823
  ((nodeVersion === null || nodeVersion === void 0 ? void 0 : nodeVersion.major) || 0) < 16) {
35069
34824
  // Ensure that npm 7 is at the beginning of the `$PATH`
35070
- env.PATH = `/node16/bin-npm7:${env.PATH}`;
34825
+ newEnv.PATH = `/node16/bin-npm7:${env.PATH}`;
35071
34826
  console.log('Detected `package-lock.json` generated by npm 7...');
35072
34827
  }
35073
34828
  }
35074
34829
  else {
35075
- opts.prettyCommand = 'yarn install';
35076
- commandArgs = ['install', ...args];
35077
34830
  // Yarn v2 PnP mode may be activated, so force "node-modules" linker style
35078
34831
  if (!env.YARN_NODE_LINKER) {
35079
- env.YARN_NODE_LINKER = 'node-modules';
34832
+ newEnv.YARN_NODE_LINKER = 'node-modules';
35080
34833
  }
35081
34834
  }
35082
- if (process.env.NPM_ONLY_PRODUCTION) {
35083
- commandArgs.push('--production');
35084
- }
35085
- return spawnAsync(cliType, commandArgs, opts);
34835
+ return newEnv;
35086
34836
  }
35087
- exports.runNpmInstall = runNpmInstall;
34837
+ exports.getEnvForPackageManager = getEnvForPackageManager;
34838
+ async function runCustomInstallCommand({ destPath, installCommand, nodeVersion, spawnOpts, }) {
34839
+ console.log(`Running "install" command: \`${installCommand}\`...`);
34840
+ const { cliType, lockfileVersion } = await scanParentDirs(destPath);
34841
+ const env = getEnvForPackageManager({
34842
+ cliType,
34843
+ lockfileVersion,
34844
+ nodeVersion,
34845
+ env: (spawnOpts === null || spawnOpts === void 0 ? void 0 : spawnOpts.env) || {},
34846
+ });
34847
+ debug_1.default(`Running with $PATH:`, (env === null || env === void 0 ? void 0 : env.PATH) || '');
34848
+ await execCommand(installCommand, {
34849
+ ...spawnOpts,
34850
+ env,
34851
+ cwd: destPath,
34852
+ });
34853
+ }
34854
+ exports.runCustomInstallCommand = runCustomInstallCommand;
35088
34855
  async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
35089
34856
  assert_1.default(path_1.default.isAbsolute(destPath));
35090
34857
  const { packageJson, cliType, lockfileVersion } = await scanParentDirs(destPath, true);
@@ -35093,21 +34860,24 @@ async function runPackageJsonScript(destPath, scriptNames, spawnOpts) {
35093
34860
  return false;
35094
34861
  debug_1.default('Running user script...');
35095
34862
  const runScriptTime = Date.now();
35096
- const opts = { cwd: destPath, ...spawnOpts };
35097
- const env = (opts.env = { ...process.env, ...opts.env });
34863
+ const opts = {
34864
+ cwd: destPath,
34865
+ ...spawnOpts,
34866
+ env: getEnvForPackageManager({
34867
+ cliType,
34868
+ lockfileVersion,
34869
+ nodeVersion: undefined,
34870
+ env: {
34871
+ ...process.env,
34872
+ ...spawnOpts === null || spawnOpts === void 0 ? void 0 : spawnOpts.env,
34873
+ },
34874
+ }),
34875
+ };
35098
34876
  if (cliType === 'npm') {
35099
34877
  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
34878
  }
35105
34879
  else {
35106
34880
  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
34881
  }
35112
34882
  console.log(`Running "${opts.prettyCommand}"`);
35113
34883
  await spawnAsync(cliType, ['run', scriptName], opts);
@@ -35257,6 +35027,40 @@ async function default_1(downloadPath, rootDirectory) {
35257
35027
  exports.default = default_1;
35258
35028
 
35259
35029
 
35030
+ /***/ }),
35031
+
35032
+ /***/ 4678:
35033
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
35034
+
35035
+ "use strict";
35036
+
35037
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
35038
+ exports.getPlatformEnv = void 0;
35039
+ const errors_1 = __webpack_require__(3983);
35040
+ /**
35041
+ * Helper function to support both `VERCEL_` and legacy `NOW_` env vars.
35042
+ * Throws an error if *both* env vars are defined.
35043
+ */
35044
+ const getPlatformEnv = (name) => {
35045
+ const vName = `VERCEL_${name}`;
35046
+ const nName = `NOW_${name}`;
35047
+ const v = process.env[vName];
35048
+ const n = process.env[nName];
35049
+ if (typeof v === 'string') {
35050
+ if (typeof n === 'string') {
35051
+ throw new errors_1.NowBuildError({
35052
+ code: 'CONFLICTING_ENV_VAR_NAMES',
35053
+ message: `Both "${vName}" and "${nName}" env vars are defined. Please only define the "${vName}" env var.`,
35054
+ link: 'https://vercel.link/combining-old-and-new-config',
35055
+ });
35056
+ }
35057
+ return v;
35058
+ }
35059
+ return n;
35060
+ };
35061
+ exports.getPlatformEnv = getPlatformEnv;
35062
+
35063
+
35260
35064
  /***/ }),
35261
35065
 
35262
35066
  /***/ 2855:
@@ -35290,7 +35094,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35290
35094
  return (mod && mod.__esModule) ? mod : { "default": mod };
35291
35095
  };
35292
35096
  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;
35097
+ exports.isStaticRuntime = exports.isOfficialRuntime = 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.getPlatformEnv = 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.NodejsLambda = exports.Lambda = exports.FileRef = exports.FileFsRef = exports.FileBlob = void 0;
35294
35098
  const file_blob_1 = __importDefault(__webpack_require__(2397));
35295
35099
  exports.FileBlob = file_blob_1.default;
35296
35100
  const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
@@ -35301,6 +35105,8 @@ const lambda_1 = __webpack_require__(6721);
35301
35105
  Object.defineProperty(exports, "Lambda", ({ enumerable: true, get: function () { return lambda_1.Lambda; } }));
35302
35106
  Object.defineProperty(exports, "createLambda", ({ enumerable: true, get: function () { return lambda_1.createLambda; } }));
35303
35107
  Object.defineProperty(exports, "getLambdaOptionsFromFunction", ({ enumerable: true, get: function () { return lambda_1.getLambdaOptionsFromFunction; } }));
35108
+ const nodejs_lambda_1 = __webpack_require__(7049);
35109
+ Object.defineProperty(exports, "NodejsLambda", ({ enumerable: true, get: function () { return nodejs_lambda_1.NodejsLambda; } }));
35304
35110
  const prerender_1 = __webpack_require__(2850);
35305
35111
  Object.defineProperty(exports, "Prerender", ({ enumerable: true, get: function () { return prerender_1.Prerender; } }));
35306
35112
  const download_1 = __importStar(__webpack_require__(1611));
@@ -35325,6 +35131,8 @@ Object.defineProperty(exports, "runNpmInstall", ({ enumerable: true, get: functi
35325
35131
  Object.defineProperty(exports, "runBundleInstall", ({ enumerable: true, get: function () { return run_user_scripts_1.runBundleInstall; } }));
35326
35132
  Object.defineProperty(exports, "runPipInstall", ({ enumerable: true, get: function () { return run_user_scripts_1.runPipInstall; } }));
35327
35133
  Object.defineProperty(exports, "runShellScript", ({ enumerable: true, get: function () { return run_user_scripts_1.runShellScript; } }));
35134
+ Object.defineProperty(exports, "runCustomInstallCommand", ({ enumerable: true, get: function () { return run_user_scripts_1.runCustomInstallCommand; } }));
35135
+ Object.defineProperty(exports, "getEnvForPackageManager", ({ enumerable: true, get: function () { return run_user_scripts_1.getEnvForPackageManager; } }));
35328
35136
  Object.defineProperty(exports, "getNodeVersion", ({ enumerable: true, get: function () { return run_user_scripts_1.getNodeVersion; } }));
35329
35137
  Object.defineProperty(exports, "getSpawnOptions", ({ enumerable: true, get: function () { return run_user_scripts_1.getSpawnOptions; } }));
35330
35138
  Object.defineProperty(exports, "getNodeBinPath", ({ enumerable: true, get: function () { return run_user_scripts_1.getNodeBinPath; } }));
@@ -35332,7 +35140,6 @@ Object.defineProperty(exports, "scanParentDirs", ({ enumerable: true, get: funct
35332
35140
  const node_version_1 = __webpack_require__(7903);
35333
35141
  Object.defineProperty(exports, "getLatestNodeVersion", ({ enumerable: true, get: function () { return node_version_1.getLatestNodeVersion; } }));
35334
35142
  Object.defineProperty(exports, "getDiscontinuedNodeVersions", ({ enumerable: true, get: function () { return node_version_1.getDiscontinuedNodeVersions; } }));
35335
- const errors_1 = __webpack_require__(3983);
35336
35143
  const stream_to_buffer_1 = __importDefault(__webpack_require__(2560));
35337
35144
  exports.streamToBuffer = stream_to_buffer_1.default;
35338
35145
  const should_serve_1 = __importDefault(__webpack_require__(2564));
@@ -35341,6 +35148,8 @@ const debug_1 = __importDefault(__webpack_require__(1868));
35341
35148
  exports.debug = debug_1.default;
35342
35149
  const get_ignore_filter_1 = __importDefault(__webpack_require__(1148));
35343
35150
  exports.getIgnoreFilter = get_ignore_filter_1.default;
35151
+ const get_platform_env_1 = __webpack_require__(4678);
35152
+ Object.defineProperty(exports, "getPlatformEnv", ({ enumerable: true, get: function () { return get_platform_env_1.getPlatformEnv; } }));
35344
35153
  var detect_builders_1 = __webpack_require__(4246);
35345
35154
  Object.defineProperty(exports, "detectBuilders", ({ enumerable: true, get: function () { return detect_builders_1.detectBuilders; } }));
35346
35155
  Object.defineProperty(exports, "detectOutputDirectory", ({ enumerable: true, get: function () { return detect_builders_1.detectOutputDirectory; } }));
@@ -35356,10 +35165,6 @@ var read_config_file_1 = __webpack_require__(7792);
35356
35165
  Object.defineProperty(exports, "readConfigFile", ({ enumerable: true, get: function () { return read_config_file_1.readConfigFile; } }));
35357
35166
  var normalize_path_1 = __webpack_require__(6261);
35358
35167
  Object.defineProperty(exports, "normalizePath", ({ enumerable: true, get: function () { return normalize_path_1.normalizePath; } }));
35359
- var convert_runtime_to_plugin_1 = __webpack_require__(7276);
35360
- Object.defineProperty(exports, "_experimental_convertRuntimeToPlugin", ({ enumerable: true, get: function () { return convert_runtime_to_plugin_1._experimental_convertRuntimeToPlugin; } }));
35361
- Object.defineProperty(exports, "_experimental_updateFunctionsManifest", ({ enumerable: true, get: function () { return convert_runtime_to_plugin_1._experimental_updateFunctionsManifest; } }));
35362
- Object.defineProperty(exports, "_experimental_updateRoutesManifest", ({ enumerable: true, get: function () { return convert_runtime_to_plugin_1._experimental_updateRoutesManifest; } }));
35363
35168
  __exportStar(__webpack_require__(2416), exports);
35364
35169
  __exportStar(__webpack_require__(5748), exports);
35365
35170
  __exportStar(__webpack_require__(3983), exports);
@@ -35380,28 +35185,6 @@ const isStaticRuntime = (name) => {
35380
35185
  return exports.isOfficialRuntime('static', name);
35381
35186
  };
35382
35187
  exports.isStaticRuntime = isStaticRuntime;
35383
- /**
35384
- * Helper function to support both `VERCEL_` and legacy `NOW_` env vars.
35385
- * Throws an error if *both* env vars are defined.
35386
- */
35387
- const getPlatformEnv = (name) => {
35388
- const vName = `VERCEL_${name}`;
35389
- const nName = `NOW_${name}`;
35390
- const v = process.env[vName];
35391
- const n = process.env[nName];
35392
- if (typeof v === 'string') {
35393
- if (typeof n === 'string') {
35394
- throw new errors_1.NowBuildError({
35395
- code: 'CONFLICTING_ENV_VAR_NAMES',
35396
- message: `Both "${vName}" and "${nName}" env vars are defined. Please only define the "${vName}" env var.`,
35397
- link: 'https://vercel.link/combining-old-and-new-config',
35398
- });
35399
- }
35400
- return v;
35401
- }
35402
- return n;
35403
- };
35404
- exports.getPlatformEnv = getPlatformEnv;
35405
35188
 
35406
35189
 
35407
35190
  /***/ }),
@@ -35415,7 +35198,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35415
35198
  return (mod && mod.__esModule) ? mod : { "default": mod };
35416
35199
  };
35417
35200
  Object.defineProperty(exports, "__esModule", ({ value: true }));
35418
- exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = exports.FILES_SYMBOL = void 0;
35201
+ exports.getLambdaOptionsFromFunction = exports.createZip = exports.createLambda = exports.Lambda = void 0;
35419
35202
  const assert_1 = __importDefault(__webpack_require__(2357));
35420
35203
  const async_sema_1 = __importDefault(__webpack_require__(5758));
35421
35204
  const yazl_1 = __webpack_require__(1223);
@@ -35423,11 +35206,30 @@ const minimatch_1 = __importDefault(__webpack_require__(9566));
35423
35206
  const fs_extra_1 = __webpack_require__(5392);
35424
35207
  const download_1 = __webpack_require__(1611);
35425
35208
  const stream_to_buffer_1 = __importDefault(__webpack_require__(2560));
35426
- exports.FILES_SYMBOL = Symbol('files');
35427
35209
  class Lambda {
35428
- constructor({ zipBuffer, handler, runtime, maxDuration, memory, environment, allowQuery, regions, }) {
35210
+ constructor({ files, handler, runtime, maxDuration, memory, environment = {}, allowQuery, regions, zipBuffer, }) {
35211
+ if (!zipBuffer) {
35212
+ assert_1.default(typeof files === 'object', '"files" must be an object');
35213
+ }
35214
+ assert_1.default(typeof handler === 'string', '"handler" is not a string');
35215
+ assert_1.default(typeof runtime === 'string', '"runtime" is not a string');
35216
+ assert_1.default(typeof environment === 'object', '"environment" is not an object');
35217
+ if (memory !== undefined) {
35218
+ assert_1.default(typeof memory === 'number', '"memory" is not a number');
35219
+ }
35220
+ if (maxDuration !== undefined) {
35221
+ assert_1.default(typeof maxDuration === 'number', '"maxDuration" is not a number');
35222
+ }
35223
+ if (allowQuery !== undefined) {
35224
+ assert_1.default(Array.isArray(allowQuery), '"allowQuery" is not an Array');
35225
+ assert_1.default(allowQuery.every(q => typeof q === 'string'), '"allowQuery" is not a string Array');
35226
+ }
35227
+ if (regions !== undefined) {
35228
+ assert_1.default(Array.isArray(regions), '"regions" is not an Array');
35229
+ assert_1.default(regions.every(r => typeof r === 'string'), '"regions" is not a string Array');
35230
+ }
35429
35231
  this.type = 'Lambda';
35430
- this.zipBuffer = zipBuffer;
35232
+ this.files = files;
35431
35233
  this.handler = handler;
35432
35234
  this.runtime = runtime;
35433
35235
  this.memory = memory;
@@ -35435,49 +35237,33 @@ class Lambda {
35435
35237
  this.environment = environment;
35436
35238
  this.allowQuery = allowQuery;
35437
35239
  this.regions = regions;
35240
+ this.zipBuffer = zipBuffer;
35241
+ }
35242
+ async createZip() {
35243
+ let { zipBuffer } = this;
35244
+ if (!zipBuffer) {
35245
+ await sema.acquire();
35246
+ try {
35247
+ zipBuffer = await createZip(this.files);
35248
+ }
35249
+ finally {
35250
+ sema.release();
35251
+ }
35252
+ }
35253
+ return zipBuffer;
35438
35254
  }
35439
35255
  }
35440
35256
  exports.Lambda = Lambda;
35441
35257
  const sema = new async_sema_1.default(10);
35442
35258
  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
- }
35259
+ /**
35260
+ * @deprecated Use `new Lambda()` instead.
35261
+ */
35262
+ async function createLambda(opts) {
35263
+ const lambda = new Lambda(opts);
35264
+ // backwards compat
35265
+ lambda.zipBuffer = await lambda.createZip();
35266
+ return lambda;
35481
35267
  }
35482
35268
  exports.createLambda = createLambda;
35483
35269
  async function createZip(files) {
@@ -35512,7 +35298,7 @@ async function createZip(files) {
35512
35298
  }
35513
35299
  exports.createZip = createZip;
35514
35300
  async function getLambdaOptionsFromFunction({ sourceFile, config, }) {
35515
- if (config && config.functions) {
35301
+ if (config === null || config === void 0 ? void 0 : config.functions) {
35516
35302
  for (const [pattern, fn] of Object.entries(config.functions)) {
35517
35303
  if (sourceFile === pattern || minimatch_1.default(sourceFile, pattern)) {
35518
35304
  return {
@@ -35527,6 +35313,28 @@ async function getLambdaOptionsFromFunction({ sourceFile, config, }) {
35527
35313
  exports.getLambdaOptionsFromFunction = getLambdaOptionsFromFunction;
35528
35314
 
35529
35315
 
35316
+ /***/ }),
35317
+
35318
+ /***/ 7049:
35319
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
35320
+
35321
+ "use strict";
35322
+
35323
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
35324
+ exports.NodejsLambda = void 0;
35325
+ const lambda_1 = __webpack_require__(6721);
35326
+ class NodejsLambda extends lambda_1.Lambda {
35327
+ constructor({ shouldAddHelpers, shouldAddSourcemapSupport, awsLambdaHandler, ...opts }) {
35328
+ super(opts);
35329
+ this.launcherType = 'Nodejs';
35330
+ this.shouldAddHelpers = shouldAddHelpers;
35331
+ this.shouldAddSourcemapSupport = shouldAddSourcemapSupport;
35332
+ this.awsLambdaHandler = awsLambdaHandler;
35333
+ }
35334
+ }
35335
+ exports.NodejsLambda = NodejsLambda;
35336
+
35337
+
35530
35338
  /***/ }),
35531
35339
 
35532
35340
  /***/ 2850: