@vercel/static-build 2.8.46 → 2.9.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.
Files changed (2) hide show
  1. package/dist/index.js +87 -11
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -22890,6 +22890,7 @@ var require_resolve = __commonJS({
22890
22890
  };
22891
22891
  }
22892
22892
  var SERVICE_NAME_REGEX = /^[a-zA-Z]([a-zA-Z0-9_-]*[a-zA-Z0-9])?$/;
22893
+ var DNS_LABEL_RE = /^(?!-)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/i;
22893
22894
  function normalizeServiceEntrypoint(entrypoint) {
22894
22895
  const normalized = import_path7.posix.normalize(entrypoint);
22895
22896
  return normalized === "" ? "." : normalized;
@@ -23020,10 +23021,19 @@ var require_resolve = __commonJS({
23020
23021
  };
23021
23022
  }
23022
23023
  const serviceType = config.type || "web";
23023
- if (serviceType === "web" && !config.routePrefix) {
23024
+ const hasRoutePrefix = typeof config.routePrefix === "string";
23025
+ const hasSubdomain = typeof config.subdomain === "string";
23026
+ if (hasSubdomain && !DNS_LABEL_RE.test(config.subdomain)) {
23027
+ return {
23028
+ code: "INVALID_SUBDOMAIN",
23029
+ message: `Web service "${name}" has invalid subdomain "${config.subdomain}". Use a single DNS label such as "api".`,
23030
+ serviceName: name
23031
+ };
23032
+ }
23033
+ if (serviceType === "web" && !hasRoutePrefix && !hasSubdomain) {
23024
23034
  return {
23025
23035
  code: "MISSING_ROUTE_PREFIX",
23026
- message: `Web service "${name}" must specify "routePrefix".`,
23036
+ message: `Web service "${name}" must specify at least one of "routePrefix" or "subdomain".`,
23027
23037
  serviceName: name
23028
23038
  };
23029
23039
  }
@@ -23041,6 +23051,13 @@ var require_resolve = __commonJS({
23041
23051
  serviceName: name
23042
23052
  };
23043
23053
  }
23054
+ if ((serviceType === "worker" || serviceType === "cron") && hasSubdomain) {
23055
+ return {
23056
+ code: "INVALID_HOST_ROUTING_CONFIG",
23057
+ message: `${serviceType === "worker" ? "Worker" : "Cron"} service "${name}" cannot have "subdomain". Only web services should specify subdomain routing.`,
23058
+ serviceName: name
23059
+ };
23060
+ }
23044
23061
  if (serviceType === "cron" && !config.schedule) {
23045
23062
  return {
23046
23063
  code: "MISSING_CRON_SCHEDULE",
@@ -23175,7 +23192,10 @@ var require_resolve = __commonJS({
23175
23192
  builderUse = (0, import_utils.getBuilderForRuntime)(inferredRuntime);
23176
23193
  builderSrc = resolvedEntrypointFile;
23177
23194
  }
23178
- const routePrefix = type === "web" && config.routePrefix ? config.routePrefix.startsWith("/") ? config.routePrefix : `/${config.routePrefix}` : void 0;
23195
+ const normalizedSubdomain = type === "web" && typeof config.subdomain === "string" ? config.subdomain.toLowerCase() : void 0;
23196
+ const defaultRoutePrefix = type === "web" && normalizedSubdomain ? `/_/${name}` : void 0;
23197
+ const routePrefix = type === "web" && (config.routePrefix || defaultRoutePrefix) ? (config.routePrefix || defaultRoutePrefix).startsWith("/") ? config.routePrefix || defaultRoutePrefix : `/${config.routePrefix || defaultRoutePrefix}` : void 0;
23198
+ const resolvedRoutePrefixSource = type === "web" && typeof routePrefix === "string" ? config.routePrefix ? routePrefixSource : "generated" : void 0;
23179
23199
  const isRoot = workspace === ".";
23180
23200
  if (!isRoot) {
23181
23201
  builderSrc = import_path7.posix.join(workspace, builderSrc);
@@ -23211,7 +23231,8 @@ var require_resolve = __commonJS({
23211
23231
  workspace,
23212
23232
  entrypoint: resolvedEntrypointFile,
23213
23233
  routePrefix,
23214
- routePrefixSource: type === "web" && typeof routePrefix === "string" ? routePrefixSource : void 0,
23234
+ routePrefixSource: resolvedRoutePrefixSource,
23235
+ subdomain: normalizedSubdomain,
23215
23236
  framework: config.framework,
23216
23237
  builder: {
23217
23238
  src: builderSrc,
@@ -23614,6 +23635,10 @@ var require_detect_services = __commonJS({
23614
23635
  var import_utils = require_utils4();
23615
23636
  var import_resolve = require_resolve();
23616
23637
  var import_auto_detect = require_auto_detect();
23638
+ var PREVIEW_DOMAIN_MISSING = [
23639
+ { type: "host", value: { suf: ".vercel.app" } },
23640
+ { type: "host", value: { suf: ".vercel.dev" } }
23641
+ ];
23617
23642
  async function detectServices2(options) {
23618
23643
  const { fs: fs5, workPath } = options;
23619
23644
  const scopedFs = workPath ? fs5.chdir(workPath) : fs5;
@@ -23622,7 +23647,13 @@ var require_detect_services = __commonJS({
23622
23647
  return {
23623
23648
  services: [],
23624
23649
  source: "configured",
23625
- routes: { rewrites: [], defaults: [], crons: [], workers: [] },
23650
+ routes: {
23651
+ hostRewrites: [],
23652
+ rewrites: [],
23653
+ defaults: [],
23654
+ crons: [],
23655
+ workers: []
23656
+ },
23626
23657
  errors: [configError],
23627
23658
  warnings: []
23628
23659
  };
@@ -23635,7 +23666,13 @@ var require_detect_services = __commonJS({
23635
23666
  return {
23636
23667
  services: [],
23637
23668
  source: "auto-detected",
23638
- routes: { rewrites: [], defaults: [], crons: [], workers: [] },
23669
+ routes: {
23670
+ hostRewrites: [],
23671
+ rewrites: [],
23672
+ defaults: [],
23673
+ crons: [],
23674
+ workers: []
23675
+ },
23639
23676
  errors: autoResult.errors,
23640
23677
  warnings: []
23641
23678
  };
@@ -23658,7 +23695,13 @@ var require_detect_services = __commonJS({
23658
23695
  return {
23659
23696
  services: [],
23660
23697
  source: "auto-detected",
23661
- routes: { rewrites: [], defaults: [], crons: [], workers: [] },
23698
+ routes: {
23699
+ hostRewrites: [],
23700
+ rewrites: [],
23701
+ defaults: [],
23702
+ crons: [],
23703
+ workers: []
23704
+ },
23662
23705
  errors: [
23663
23706
  {
23664
23707
  code: "NO_SERVICES_CONFIGURED",
@@ -23683,6 +23726,7 @@ var require_detect_services = __commonJS({
23683
23726
  };
23684
23727
  }
23685
23728
  function generateServicesRoutes2(services) {
23729
+ const hostRewrites = [];
23686
23730
  const rewrites = [];
23687
23731
  const defaults = [];
23688
23732
  const crons = [];
@@ -23695,6 +23739,25 @@ var require_detect_services = __commonJS({
23695
23739
  const { routePrefix } = service;
23696
23740
  const normalizedPrefix = routePrefix.slice(1);
23697
23741
  const ownershipGuard = (0, import_routing_utils.getOwnershipGuard)(routePrefix, allWebPrefixes);
23742
+ const hostCondition = getHostCondition(service);
23743
+ if (hostCondition && routePrefix !== "/") {
23744
+ const normalizedRoutePrefix = (0, import_routing_utils.normalizeRoutePrefix)(routePrefix);
23745
+ const escapedPrefix = escapeRegex(normalizedRoutePrefix.slice(1));
23746
+ hostRewrites.push({
23747
+ src: "^/$",
23748
+ dest: normalizedRoutePrefix,
23749
+ has: hostCondition,
23750
+ missing: PREVIEW_DOMAIN_MISSING,
23751
+ check: true
23752
+ });
23753
+ hostRewrites.push({
23754
+ src: `^/(?!${escapedPrefix}(?:/|$))(.*)$`,
23755
+ dest: `${normalizedRoutePrefix}/$1`,
23756
+ has: hostCondition,
23757
+ missing: PREVIEW_DOMAIN_MISSING,
23758
+ check: true
23759
+ });
23760
+ }
23698
23761
  if ((0, import_utils.isRouteOwningBuilder)(service)) {
23699
23762
  continue;
23700
23763
  }
@@ -23764,7 +23827,7 @@ var require_detect_services = __commonJS({
23764
23827
  check: true
23765
23828
  });
23766
23829
  }
23767
- return { rewrites, defaults, crons, workers };
23830
+ return { hostRewrites, rewrites, defaults, crons, workers };
23768
23831
  }
23769
23832
  function escapeRegex(str) {
23770
23833
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -23779,6 +23842,15 @@ var require_detect_services = __commonJS({
23779
23842
  }
23780
23843
  return Array.from(unique);
23781
23844
  }
23845
+ function getHostCondition(service) {
23846
+ if (service.type !== "web") {
23847
+ return void 0;
23848
+ }
23849
+ if (typeof service.subdomain === "string" && service.subdomain.length > 0) {
23850
+ return [{ type: "host", value: { pre: `${service.subdomain}.` } }];
23851
+ }
23852
+ return void 0;
23853
+ }
23782
23854
  }
23783
23855
  });
23784
23856
 
@@ -24019,6 +24091,7 @@ var require_get_services_builders = __commonJS({
24019
24091
  }
24020
24092
  ],
24021
24093
  warnings: [],
24094
+ hostRewriteRoutes: null,
24022
24095
  defaultRoutes: null,
24023
24096
  redirectRoutes: null,
24024
24097
  rewriteRoutes: null,
@@ -24039,6 +24112,7 @@ var require_get_services_builders = __commonJS({
24039
24112
  message: e.message
24040
24113
  })),
24041
24114
  warnings: warningResponses,
24115
+ hostRewriteRoutes: null,
24042
24116
  defaultRoutes: null,
24043
24117
  redirectRoutes: null,
24044
24118
  rewriteRoutes: null,
@@ -24055,6 +24129,7 @@ var require_get_services_builders = __commonJS({
24055
24129
  }
24056
24130
  ],
24057
24131
  warnings: warningResponses,
24132
+ hostRewriteRoutes: null,
24058
24133
  defaultRoutes: null,
24059
24134
  redirectRoutes: null,
24060
24135
  rewriteRoutes: null,
@@ -24066,6 +24141,7 @@ var require_get_services_builders = __commonJS({
24066
24141
  builders: builders.length > 0 ? builders : null,
24067
24142
  errors: null,
24068
24143
  warnings: warningResponses,
24144
+ hostRewriteRoutes: result.routes.hostRewrites.length > 0 ? result.routes.hostRewrites : null,
24069
24145
  defaultRoutes: result.routes.defaults.length > 0 ? result.routes.defaults : null,
24070
24146
  redirectRoutes: [],
24071
24147
  rewriteRoutes: result.routes.rewrites.length > 0 || result.routes.workers.length > 0 || result.routes.crons.length > 0 ? [
@@ -24545,10 +24621,10 @@ var require_detect_builders = __commonJS({
24545
24621
  message: "Function must contain at least one property."
24546
24622
  };
24547
24623
  }
24548
- if (func.maxDuration !== void 0 && (func.maxDuration < 1 || func.maxDuration > 900 || !Number.isInteger(func.maxDuration))) {
24624
+ if (func.maxDuration !== void 0 && func.maxDuration !== "max" && (func.maxDuration < 1 || func.maxDuration > 900 || !Number.isInteger(func.maxDuration))) {
24549
24625
  return {
24550
24626
  code: "invalid_function_duration",
24551
- message: "Functions must have a duration between 1 and 900."
24627
+ message: 'Functions must have a maxDuration between 1 and 900, or "max".'
24552
24628
  };
24553
24629
  }
24554
24630
  if (func.memory !== void 0 && (func.memory < 128 || func.memory > 10240)) {
@@ -32590,7 +32666,7 @@ function parseFunctionConfig(data) {
32590
32666
  if (typeof data.memory === "number") {
32591
32667
  config.memory = data.memory;
32592
32668
  }
32593
- if (typeof data.maxDuration === "number") {
32669
+ if (typeof data.maxDuration === "number" || data.maxDuration === "max") {
32594
32670
  config.maxDuration = data.maxDuration;
32595
32671
  }
32596
32672
  if (typeof data.runtime === "string" && typeof data.handler === "string") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "2.8.46",
3
+ "version": "2.9.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -15,8 +15,8 @@
15
15
  "dependencies": {
16
16
  "ts-morph": "12.0.0",
17
17
  "@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
18
- "@vercel/gatsby-plugin-vercel-builder": "2.0.144",
19
- "@vercel/static-config": "3.1.2"
18
+ "@vercel/gatsby-plugin-vercel-builder": "2.1.0",
19
+ "@vercel/static-config": "3.2.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/aws-lambda": "8.10.64",
@@ -38,11 +38,11 @@
38
38
  "rc9": "1.2.0",
39
39
  "semver": "7.5.2",
40
40
  "tree-kill": "1.2.2",
41
- "@vercel/build-utils": "13.7.0",
42
- "@vercel/error-utils": "2.0.3",
41
+ "@vercel/build-utils": "13.8.0",
43
42
  "@vercel/frameworks": "3.20.0",
44
- "@vercel/routing-utils": "6.0.2",
45
- "@vercel/fs-detectors": "5.9.0"
43
+ "@vercel/error-utils": "2.0.3",
44
+ "@vercel/fs-detectors": "5.10.0",
45
+ "@vercel/routing-utils": "6.0.2"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "node ../../utils/build-builder.mjs",