@vercel/static-build 2.9.1 → 2.9.2

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.
Files changed (2) hide show
  1. package/dist/index.js +126 -74
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -22383,7 +22383,7 @@ var require_types3 = __commonJS({
22383
22383
  });
22384
22384
  module2.exports = __toCommonJS2(types_exports);
22385
22385
  var RUNTIME_BUILDERS = {
22386
- node: "@vercel/node",
22386
+ node: "@vercel/backends",
22387
22387
  python: "@vercel/python",
22388
22388
  go: "@vercel/go",
22389
22389
  rust: "@vercel/rust",
@@ -22461,6 +22461,7 @@ var require_utils4 = __commonJS({
22461
22461
  hasFile: () => hasFile,
22462
22462
  inferRuntimeFromFramework: () => inferRuntimeFromFramework,
22463
22463
  inferServiceRuntime: () => inferServiceRuntime,
22464
+ isFrontendFramework: () => isFrontendFramework,
22464
22465
  isRouteOwningBuilder: () => isRouteOwningBuilder2,
22465
22466
  isStaticBuild: () => isStaticBuild2,
22466
22467
  readVercelConfig: () => readVercelConfig
@@ -22526,6 +22527,12 @@ var require_utils4 = __commonJS({
22526
22527
  }
22527
22528
  return void 0;
22528
22529
  }
22530
+ function isFrontendFramework(framework) {
22531
+ if (!framework) {
22532
+ return false;
22533
+ }
22534
+ return !inferRuntimeFromFramework(framework);
22535
+ }
22529
22536
  function filterFrameworksByRuntime(frameworks2, runtime) {
22530
22537
  if (!runtime) {
22531
22538
  return [...frameworks2];
@@ -22836,11 +22843,9 @@ var require_detect_framework = __commonJS({
22836
22843
  var require_resolve = __commonJS({
22837
22844
  "../fs-detectors/dist/services/resolve.js"(exports2, module2) {
22838
22845
  "use strict";
22839
- var __create2 = Object.create;
22840
22846
  var __defProp2 = Object.defineProperty;
22841
22847
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
22842
22848
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
22843
- var __getProtoOf2 = Object.getPrototypeOf;
22844
22849
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
22845
22850
  var __export2 = (target, all) => {
22846
22851
  for (var name in all)
@@ -22854,14 +22859,6 @@ var require_resolve = __commonJS({
22854
22859
  }
22855
22860
  return to;
22856
22861
  };
22857
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
22858
- // If the importer is in node compatibility mode or this is not an ESM
22859
- // file that has been converted to a CommonJS file using a Babel-
22860
- // compatible transform (i.e. "__esModule" has not been set), then set
22861
- // "default" to the CommonJS "module.exports" for node compatibility.
22862
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
22863
- mod
22864
- ));
22865
22862
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
22866
22863
  var resolve_exports = {};
22867
22864
  __export2(resolve_exports, {
@@ -22874,10 +22871,11 @@ var require_resolve = __commonJS({
22874
22871
  var import_path7 = require("path");
22875
22872
  var import_types = require_types3();
22876
22873
  var import_utils = require_utils4();
22877
- var import_frameworks2 = __toESM2(require_frameworks());
22874
+ var import_frameworks2 = require_frameworks();
22878
22875
  var import_detect_framework = require_detect_framework();
22879
22876
  var import_routing_utils = require_dist6();
22880
- var frameworksBySlug = new Map(import_frameworks2.default.map((f) => [f.slug, f]));
22877
+ var import_build_utils5 = require("@vercel/build-utils");
22878
+ var frameworksBySlug = new Map(import_frameworks2.frameworkList.map((f) => [f.slug, f]));
22881
22879
  var PYTHON_MODULE_ATTR_RE = /^([A-Za-z_][\w]*(?:\.[A-Za-z_][\w]*)*):([A-Za-z_][\w]*)$/;
22882
22880
  function parsePyModuleAttrEntrypoint(entrypoint) {
22883
22881
  const match = PYTHON_MODULE_ATTR_RE.exec(entrypoint);
@@ -22978,7 +22976,7 @@ var require_resolve = __commonJS({
22978
22976
  runtime
22979
22977
  }) {
22980
22978
  const serviceFs = workspace === "." ? fs5 : fs5.chdir(workspace);
22981
- const frameworkCandidates = (0, import_utils.filterFrameworksByRuntime)(import_frameworks2.default, runtime);
22979
+ const frameworkCandidates = (0, import_utils.filterFrameworksByRuntime)(import_frameworks2.frameworkList, runtime);
22982
22980
  const frameworks2 = await (0, import_detect_framework.detectFrameworks)({
22983
22981
  fs: serviceFs,
22984
22982
  frameworkList: frameworkCandidates
@@ -23110,6 +23108,7 @@ var require_resolve = __commonJS({
23110
23108
  function validateServiceEntrypoint(name, config, resolvedEntrypoint) {
23111
23109
  if (!resolvedEntrypoint.isDirectory && !config.builder && !config.runtime && !config.framework) {
23112
23110
  const runtime = (0, import_utils.inferServiceRuntime)({
23111
+ ...config,
23113
23112
  entrypoint: resolvedEntrypoint.normalized
23114
23113
  });
23115
23114
  if (!runtime) {
@@ -23180,15 +23179,28 @@ var require_resolve = __commonJS({
23180
23179
  const consumer = type === "worker" ? config.consumer || "default" : config.consumer;
23181
23180
  let builderUse;
23182
23181
  let builderSrc;
23183
- if (config.framework) {
23184
- const framework = frameworksBySlug.get(config.framework);
23185
- builderUse = framework?.useRuntime?.use || "@vercel/static-build";
23186
- builderSrc = resolvedEntrypointFile || framework?.useRuntime?.src || "package.json";
23187
- } else if (config.builder) {
23182
+ const frameworkDefinition = config.framework ? frameworksBySlug.get(config.framework) : void 0;
23183
+ if (config.builder) {
23188
23184
  builderUse = config.builder;
23189
- builderSrc = resolvedEntrypointFile;
23185
+ builderSrc = resolvedEntrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
23186
+ } else if (config.framework) {
23187
+ if (type === "web" && (0, import_build_utils5.isNodeBackendFramework)(config.framework)) {
23188
+ builderUse = "@vercel/backends";
23189
+ } else {
23190
+ builderUse = frameworkDefinition?.useRuntime?.use || "@vercel/static-build";
23191
+ }
23192
+ builderSrc = resolvedEntrypointFile || frameworkDefinition?.useRuntime?.src || "package.json";
23190
23193
  } else {
23191
- builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
23194
+ if (!inferredRuntime) {
23195
+ throw new Error(
23196
+ `Could not infer runtime for service "${name}" and no builder or framework were provided.`
23197
+ );
23198
+ }
23199
+ if (inferredRuntime === "node") {
23200
+ builderUse = type === "web" ? "@vercel/backends" : "@vercel/node";
23201
+ } else {
23202
+ builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
23203
+ }
23192
23204
  builderSrc = resolvedEntrypointFile;
23193
23205
  }
23194
23206
  const normalizedSubdomain = type === "web" && typeof config.subdomain === "string" ? config.subdomain.toLowerCase() : void 0;
@@ -23200,6 +23212,9 @@ var require_resolve = __commonJS({
23200
23212
  builderSrc = import_path7.posix.join(workspace, builderSrc);
23201
23213
  }
23202
23214
  const builderConfig = { zeroConfig: true };
23215
+ if (builderUse === "@vercel/backends") {
23216
+ builderConfig.serviceName = name;
23217
+ }
23203
23218
  if (config.memory)
23204
23219
  builderConfig.memory = config.memory;
23205
23220
  if (config.maxDuration)
@@ -23288,10 +23303,14 @@ var require_resolve = __commonJS({
23288
23303
  let resolvedConfig = serviceConfig;
23289
23304
  if (!serviceConfig.framework && resolvedEntrypoint) {
23290
23305
  if (resolvedEntrypoint.isDirectory) {
23306
+ const inferredRuntime = (0, import_utils.inferServiceRuntime)({
23307
+ ...serviceConfig
23308
+ });
23291
23309
  const workspace = resolvedEntrypoint.normalized;
23292
23310
  const { framework, error } = await detectFrameworkFromWorkspace({
23293
23311
  fs: fs5,
23294
23312
  workspace,
23313
+ runtime: inferredRuntime,
23295
23314
  serviceName: name
23296
23315
  });
23297
23316
  if (error) {
@@ -23328,7 +23347,7 @@ var require_resolve = __commonJS({
23328
23347
  serviceName: name,
23329
23348
  runtime: inferredRuntime
23330
23349
  });
23331
- if (detection.framework) {
23350
+ if (!detection.error && detection.framework) {
23332
23351
  resolvedConfig = {
23333
23352
  ...resolvedConfig,
23334
23353
  framework: detection.framework
@@ -23370,11 +23389,9 @@ var require_resolve = __commonJS({
23370
23389
  var require_auto_detect = __commonJS({
23371
23390
  "../fs-detectors/dist/services/auto-detect.js"(exports2, module2) {
23372
23391
  "use strict";
23373
- var __create2 = Object.create;
23374
23392
  var __defProp2 = Object.defineProperty;
23375
23393
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
23376
23394
  var __getOwnPropNames2 = Object.getOwnPropertyNames;
23377
- var __getProtoOf2 = Object.getPrototypeOf;
23378
23395
  var __hasOwnProp2 = Object.prototype.hasOwnProperty;
23379
23396
  var __export2 = (target, all) => {
23380
23397
  for (var name in all)
@@ -23388,14 +23405,6 @@ var require_auto_detect = __commonJS({
23388
23405
  }
23389
23406
  return to;
23390
23407
  };
23391
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
23392
- // If the importer is in node compatibility mode or this is not an ESM
23393
- // file that has been converted to a CommonJS file using a Babel-
23394
- // compatible transform (i.e. "__esModule" has not been set), then set
23395
- // "default" to the CommonJS "module.exports" for node compatibility.
23396
- isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
23397
- mod
23398
- ));
23399
23408
  var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
23400
23409
  var auto_detect_exports = {};
23401
23410
  __export2(auto_detect_exports, {
@@ -23403,20 +23412,20 @@ var require_auto_detect = __commonJS({
23403
23412
  });
23404
23413
  module2.exports = __toCommonJS2(auto_detect_exports);
23405
23414
  var import_detect_framework = require_detect_framework();
23406
- var import_frameworks2 = __toESM2(require_frameworks());
23415
+ var import_frameworks2 = require_frameworks();
23407
23416
  var FRONTEND_DIR = "frontend";
23408
23417
  var APPS_WEB_DIR = "apps/web";
23409
23418
  var BACKEND_DIR = "backend";
23410
23419
  var SERVICES_DIR = "services";
23411
23420
  var FRONTEND_LOCATIONS = [FRONTEND_DIR, APPS_WEB_DIR];
23412
- var DETECTION_FRAMEWORKS = import_frameworks2.default.filter(
23421
+ var DETECTION_FRAMEWORKS = import_frameworks2.frameworkList.filter(
23413
23422
  (framework) => !framework.experimental || framework.runtimeFramework
23414
23423
  );
23415
23424
  async function autoDetectServices2(options) {
23416
23425
  const { fs: fs5 } = options;
23417
23426
  const rootFrameworks = await (0, import_detect_framework.detectFrameworks)({
23418
23427
  fs: fs5,
23419
- frameworkList: import_frameworks2.default
23428
+ frameworkList: import_frameworks2.frameworkList
23420
23429
  });
23421
23430
  if (rootFrameworks.length > 1) {
23422
23431
  const frameworkNames = rootFrameworks.map((f) => f.name).join(", ");
@@ -23441,7 +23450,7 @@ var require_auto_detect = __commonJS({
23441
23450
  const frontendFs = fs5.chdir(frontendLocation);
23442
23451
  const frontendFrameworks = await (0, import_detect_framework.detectFrameworks)({
23443
23452
  fs: frontendFs,
23444
- frameworkList: import_frameworks2.default
23453
+ frameworkList: import_frameworks2.frameworkList
23445
23454
  });
23446
23455
  if (frontendFrameworks.length > 1) {
23447
23456
  const frameworkNames = frontendFrameworks.map((f) => f.name).join(", ");
@@ -23481,13 +23490,22 @@ var require_auto_detect = __commonJS({
23481
23490
  };
23482
23491
  const backendResult = await detectBackendServices(fs5);
23483
23492
  if (backendResult.error) {
23484
- return { services: null, errors: [backendResult.error] };
23493
+ return {
23494
+ services: null,
23495
+ errors: [backendResult.error]
23496
+ };
23485
23497
  }
23486
23498
  if (Object.keys(backendResult.services).length === 0) {
23487
- return { services: null, errors: [] };
23499
+ return {
23500
+ services: null,
23501
+ errors: []
23502
+ };
23488
23503
  }
23489
23504
  Object.assign(services, backendResult.services);
23490
- return { services, errors: [] };
23505
+ return {
23506
+ services,
23507
+ errors: []
23508
+ };
23491
23509
  }
23492
23510
  async function detectServicesFrontendSubdir(fs5, frontendFramework, frontendLocation) {
23493
23511
  const services = {};
@@ -23499,7 +23517,10 @@ var require_auto_detect = __commonJS({
23499
23517
  };
23500
23518
  const backendResult = await detectBackendServices(fs5);
23501
23519
  if (backendResult.error) {
23502
- return { services: null, errors: [backendResult.error] };
23520
+ return {
23521
+ services: null,
23522
+ errors: [backendResult.error]
23523
+ };
23503
23524
  }
23504
23525
  if (Object.keys(backendResult.services).length === 0) {
23505
23526
  return {
@@ -23513,7 +23534,10 @@ var require_auto_detect = __commonJS({
23513
23534
  };
23514
23535
  }
23515
23536
  Object.assign(services, backendResult.services);
23516
- return { services, errors: [] };
23537
+ return {
23538
+ services,
23539
+ errors: []
23540
+ };
23517
23541
  }
23518
23542
  async function detectBackendServices(fs5) {
23519
23543
  const services = {};
@@ -23638,43 +23662,68 @@ var require_detect_services = __commonJS({
23638
23662
  { type: "host", value: { suf: ".vercel.app" } },
23639
23663
  { type: "host", value: { suf: ".vercel.dev" } }
23640
23664
  ];
23665
+ function emptyRoutes() {
23666
+ return {
23667
+ hostRewrites: [],
23668
+ rewrites: [],
23669
+ defaults: [],
23670
+ crons: [],
23671
+ workers: []
23672
+ };
23673
+ }
23674
+ function withResolvedResult(resolved, inferred = null) {
23675
+ return {
23676
+ services: resolved.services,
23677
+ source: resolved.source,
23678
+ routes: resolved.routes,
23679
+ errors: resolved.errors,
23680
+ warnings: resolved.warnings,
23681
+ resolved,
23682
+ inferred
23683
+ };
23684
+ }
23685
+ function toInferredLayoutConfig(services) {
23686
+ const inferredConfig = {};
23687
+ for (const [name, service] of Object.entries(services)) {
23688
+ const serviceConfig = {};
23689
+ if (typeof service.entrypoint === "string") {
23690
+ serviceConfig.entrypoint = service.entrypoint;
23691
+ }
23692
+ if (typeof service.routePrefix === "string") {
23693
+ serviceConfig.routePrefix = service.routePrefix;
23694
+ }
23695
+ if ((0, import_utils.isFrontendFramework)(service.framework)) {
23696
+ serviceConfig.framework = service.framework;
23697
+ }
23698
+ inferredConfig[name] = serviceConfig;
23699
+ }
23700
+ return inferredConfig;
23701
+ }
23641
23702
  async function detectServices2(options) {
23642
23703
  const { fs: fs5, workPath } = options;
23643
23704
  const scopedFs = workPath ? fs5.chdir(workPath) : fs5;
23644
23705
  const { config: vercelConfig, error: configError } = await (0, import_utils.readVercelConfig)(scopedFs);
23645
23706
  if (configError) {
23646
- return {
23707
+ return withResolvedResult({
23647
23708
  services: [],
23648
23709
  source: "configured",
23649
- routes: {
23650
- hostRewrites: [],
23651
- rewrites: [],
23652
- defaults: [],
23653
- crons: [],
23654
- workers: []
23655
- },
23710
+ routes: emptyRoutes(),
23656
23711
  errors: [configError],
23657
23712
  warnings: []
23658
- };
23713
+ });
23659
23714
  }
23660
23715
  const configuredServices = vercelConfig?.experimentalServices;
23661
23716
  const hasConfiguredServices = configuredServices && Object.keys(configuredServices).length > 0;
23662
23717
  if (!hasConfiguredServices) {
23663
23718
  const autoResult = await (0, import_auto_detect.autoDetectServices)({ fs: scopedFs });
23664
23719
  if (autoResult.errors.length > 0) {
23665
- return {
23720
+ return withResolvedResult({
23666
23721
  services: [],
23667
23722
  source: "auto-detected",
23668
- routes: {
23669
- hostRewrites: [],
23670
- rewrites: [],
23671
- defaults: [],
23672
- crons: [],
23673
- workers: []
23674
- },
23723
+ routes: emptyRoutes(),
23675
23724
  errors: autoResult.errors,
23676
23725
  warnings: []
23677
- };
23726
+ });
23678
23727
  }
23679
23728
  if (autoResult.services) {
23680
23729
  const result2 = await (0, import_resolve.resolveAllConfiguredServices)(
@@ -23683,24 +23732,28 @@ var require_detect_services = __commonJS({
23683
23732
  "generated"
23684
23733
  );
23685
23734
  const routes2 = generateServicesRoutes2(result2.services);
23686
- return {
23735
+ const resolved = {
23687
23736
  services: result2.services,
23688
23737
  source: "auto-detected",
23689
23738
  routes: routes2,
23690
23739
  errors: result2.errors,
23691
23740
  warnings: []
23692
23741
  };
23742
+ const rootWebFrameworkServices = result2.services.filter(
23743
+ (service) => service.type === "web" && service.routePrefix === "/" && typeof service.framework === "string"
23744
+ );
23745
+ const inferred = result2.errors.length === 0 && rootWebFrameworkServices.length === 1 && result2.services.length > 1 ? {
23746
+ source: "layout",
23747
+ config: toInferredLayoutConfig(autoResult.services),
23748
+ services: result2.services,
23749
+ warnings: []
23750
+ } : null;
23751
+ return withResolvedResult(resolved, inferred);
23693
23752
  }
23694
- return {
23753
+ return withResolvedResult({
23695
23754
  services: [],
23696
23755
  source: "auto-detected",
23697
- routes: {
23698
- hostRewrites: [],
23699
- rewrites: [],
23700
- defaults: [],
23701
- crons: [],
23702
- workers: []
23703
- },
23756
+ routes: emptyRoutes(),
23704
23757
  errors: [
23705
23758
  {
23706
23759
  code: "NO_SERVICES_CONFIGURED",
@@ -23708,7 +23761,7 @@ var require_detect_services = __commonJS({
23708
23761
  }
23709
23762
  ],
23710
23763
  warnings: []
23711
- };
23764
+ });
23712
23765
  }
23713
23766
  const result = await (0, import_resolve.resolveAllConfiguredServices)(
23714
23767
  configuredServices,
@@ -23716,13 +23769,13 @@ var require_detect_services = __commonJS({
23716
23769
  "configured"
23717
23770
  );
23718
23771
  const routes = generateServicesRoutes2(result.services);
23719
- return {
23772
+ return withResolvedResult({
23720
23773
  services: result.services,
23721
23774
  source: "configured",
23722
23775
  routes,
23723
23776
  errors: result.errors,
23724
23777
  warnings: []
23725
- };
23778
+ });
23726
23779
  }
23727
23780
  function generateServicesRoutes2(services) {
23728
23781
  const hostRewrites = [];
@@ -23796,7 +23849,6 @@ var require_detect_services = __commonJS({
23796
23849
  check: true
23797
23850
  });
23798
23851
  }
23799
- } else {
23800
23852
  }
23801
23853
  }
23802
23854
  const workerServices = services.filter((s) => s.type === "worker");
@@ -24213,7 +24265,7 @@ var require_detect_builders = __commonJS({
24213
24265
  var import_minimatch = __toESM2(require_minimatch());
24214
24266
  var import_semver2 = require_semver3();
24215
24267
  var import_path7 = require("path");
24216
- var import_frameworks2 = __toESM2(require_frameworks());
24268
+ var import_frameworks2 = require_frameworks();
24217
24269
  var import_is_official_runtime = require_is_official_runtime();
24218
24270
  var import_build_utils5 = require("@vercel/build-utils");
24219
24271
  var import_get_services_builders = require_get_services_builders();
@@ -24221,7 +24273,7 @@ var require_detect_builders = __commonJS({
24221
24273
  var REGEX_VERCEL_PLATFORM_FILES = `api/**,package.json,${REGEX_MIDDLEWARE_FILES}`;
24222
24274
  var REGEX_NON_VERCEL_PLATFORM_FILES2 = `!{${REGEX_VERCEL_PLATFORM_FILES}}`;
24223
24275
  var slugToFramework = new Map(
24224
- import_frameworks2.default.map((f) => [f.slug, f])
24276
+ import_frameworks2.frameworkList.map((f) => [f.slug, f])
24225
24277
  );
24226
24278
  function sortFiles(fileA, fileB) {
24227
24279
  return fileA.localeCompare(fileB);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "2.9.1",
3
+ "version": "2.9.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -14,9 +14,9 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "ts-morph": "12.0.0",
17
+ "@vercel/gatsby-plugin-vercel-builder": "2.1.2",
17
18
  "@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
18
- "@vercel/static-config": "3.2.0",
19
- "@vercel/gatsby-plugin-vercel-builder": "2.1.1"
19
+ "@vercel/static-config": "3.2.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/aws-lambda": "8.10.64",
@@ -38,10 +38,10 @@
38
38
  "rc9": "1.2.0",
39
39
  "semver": "7.5.2",
40
40
  "tree-kill": "1.2.2",
41
- "@vercel/build-utils": "13.8.1",
41
+ "@vercel/build-utils": "13.8.2",
42
42
  "@vercel/frameworks": "3.21.1",
43
- "@vercel/fs-detectors": "5.11.0",
44
43
  "@vercel/error-utils": "2.0.3",
44
+ "@vercel/fs-detectors": "5.11.2",
45
45
  "@vercel/routing-utils": "6.0.2"
46
46
  },
47
47
  "scripts": {