@vercel/static-build 2.8.43 → 2.8.45

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 +170 -46
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -8421,10 +8421,10 @@ var require_frameworks = __commonJS({
8421
8421
  const nowRoutes = JSON.parse(content);
8422
8422
  try {
8423
8423
  await unlink(nowRoutesPath);
8424
- } catch (err) {
8424
+ } catch (_err) {
8425
8425
  }
8426
8426
  return nowRoutes;
8427
- } catch (err) {
8427
+ } catch (_err) {
8428
8428
  return [
8429
8429
  {
8430
8430
  src: "^/static/(.*)$",
@@ -10407,6 +10407,11 @@ var require_frameworks = __commonJS({
10407
10407
  {
10408
10408
  path: "Pipfile",
10409
10409
  matchContent: "[Dd]jango"
10410
+ },
10411
+ {
10412
+ // a default django project will create a manage.py which sets DJANGO_SETTINGS_MODULE
10413
+ path: "manage.py",
10414
+ matchContent: "DJANGO_SETTINGS_MODULE"
10410
10415
  }
10411
10416
  ]
10412
10417
  },
@@ -20683,7 +20688,7 @@ var require_superstatic = __commonJS({
20683
20688
  route.missing = r.missing;
20684
20689
  }
20685
20690
  return route;
20686
- } catch (e) {
20691
+ } catch (_e) {
20687
20692
  throw new Error(`Failed to parse redirect: ${JSON.stringify(r)}`);
20688
20693
  }
20689
20694
  });
@@ -20716,7 +20721,7 @@ var require_superstatic = __commonJS({
20716
20721
  route.status = r.statusCode;
20717
20722
  }
20718
20723
  return route;
20719
- } catch (e) {
20724
+ } catch (_e) {
20720
20725
  throw new Error(`Failed to parse rewrite: ${JSON.stringify(r)}`);
20721
20726
  }
20722
20727
  });
@@ -20927,7 +20932,7 @@ var require_superstatic = __commonJS({
20927
20932
  if (attemptDirectCompile) {
20928
20933
  try {
20929
20934
  return (0, import_path_to_regexp.compile)(value, { validate: false })(indexes);
20930
- } catch (e) {
20935
+ } catch (_e) {
20931
20936
  }
20932
20937
  }
20933
20938
  for (const key of Object.keys(indexes)) {
@@ -22123,7 +22128,7 @@ var require_dist6 = __commonJS({
22123
22128
  function checkRegexSyntax(type, index, src) {
22124
22129
  try {
22125
22130
  new RegExp(src);
22126
- } catch (err) {
22131
+ } catch (_err) {
22127
22132
  const prop = type === "Route" ? "src`/`source" : "source";
22128
22133
  return `${type} at index ${index} has invalid \`${prop}\` regular expression "${src}".`;
22129
22134
  }
@@ -22138,7 +22143,7 @@ var require_dist6 = __commonJS({
22138
22143
  const destinationSegments = /* @__PURE__ */ new Set();
22139
22144
  try {
22140
22145
  sourceSegments = new Set((0, import_superstatic.sourceToRegex)(source).segments);
22141
- } catch (err) {
22146
+ } catch (_err) {
22142
22147
  return {
22143
22148
  message: `${type} at index ${index} has invalid \`source\` pattern "${source}".`,
22144
22149
  link: "https://vercel.link/invalid-route-source-pattern"
@@ -22159,7 +22164,7 @@ var require_dist6 = __commonJS({
22159
22164
  (name) => destinationSegments.add(name)
22160
22165
  );
22161
22166
  }
22162
- } catch (err) {
22167
+ } catch (_err) {
22163
22168
  }
22164
22169
  const hasSegments = (0, import_superstatic.collectHasSegments)(has);
22165
22170
  for (const segment of destinationSegments) {
@@ -22445,9 +22450,15 @@ var require_utils4 = __commonJS({
22445
22450
  var utils_exports = {};
22446
22451
  __export2(utils_exports, {
22447
22452
  INTERNAL_SERVICE_PREFIX: () => INTERNAL_SERVICE_PREFIX2,
22453
+ filterFrameworksByRuntime: () => filterFrameworksByRuntime,
22448
22454
  getBuilderForRuntime: () => getBuilderForRuntime,
22455
+ getInternalServiceCronPath: () => getInternalServiceCronPath2,
22456
+ getInternalServiceCronPathPrefix: () => getInternalServiceCronPathPrefix2,
22449
22457
  getInternalServiceFunctionPath: () => getInternalServiceFunctionPath2,
22458
+ getInternalServiceWorkerPath: () => getInternalServiceWorkerPath2,
22459
+ getInternalServiceWorkerPathPrefix: () => getInternalServiceWorkerPathPrefix2,
22450
22460
  hasFile: () => hasFile,
22461
+ inferRuntimeFromFramework: () => inferRuntimeFromFramework,
22451
22462
  inferServiceRuntime: () => inferServiceRuntime,
22452
22463
  isRouteOwningBuilder: () => isRouteOwningBuilder2,
22453
22464
  isStaticBuild: () => isStaticBuild2,
@@ -22467,6 +22478,24 @@ var require_utils4 = __commonJS({
22467
22478
  function getInternalServiceFunctionPath2(serviceName) {
22468
22479
  return `${INTERNAL_SERVICE_PREFIX2}/${serviceName}/index`;
22469
22480
  }
22481
+ function normalizeInternalServiceEntrypoint(entrypoint) {
22482
+ const normalized = entrypoint.replace(/\\/g, "/").replace(/^\/+/, "").replace(/\.[^/.]+$/, "");
22483
+ return normalized || "index";
22484
+ }
22485
+ function getInternalServiceWorkerPathPrefix2(serviceName) {
22486
+ return `${INTERNAL_SERVICE_PREFIX2}/${serviceName}/workers`;
22487
+ }
22488
+ function getInternalServiceCronPathPrefix2(serviceName) {
22489
+ return `${INTERNAL_SERVICE_PREFIX2}/${serviceName}/crons`;
22490
+ }
22491
+ function getInternalServiceWorkerPath2(serviceName, entrypoint, handler = "worker") {
22492
+ const normalizedEntrypoint = normalizeInternalServiceEntrypoint(entrypoint);
22493
+ return `${getInternalServiceWorkerPathPrefix2(serviceName)}/${normalizedEntrypoint}/${handler}`;
22494
+ }
22495
+ function getInternalServiceCronPath2(serviceName, entrypoint, handler = "cron") {
22496
+ const normalizedEntrypoint = normalizeInternalServiceEntrypoint(entrypoint);
22497
+ return `${getInternalServiceCronPathPrefix2(serviceName)}/${normalizedEntrypoint}/${handler}`;
22498
+ }
22470
22499
  function getBuilderForRuntime(runtime) {
22471
22500
  const builder = import_types.RUNTIME_BUILDERS[runtime];
22472
22501
  if (!builder) {
@@ -22480,19 +22509,37 @@ var require_utils4 = __commonJS({
22480
22509
  function isRouteOwningBuilder2(service) {
22481
22510
  return import_types.ROUTE_OWNING_BUILDERS.has(service.builder.use);
22482
22511
  }
22483
- function inferServiceRuntime(config) {
22484
- if (config.runtime && config.runtime in import_types.RUNTIME_BUILDERS) {
22485
- return config.runtime;
22512
+ function inferRuntimeFromFramework(framework) {
22513
+ if (!framework) {
22514
+ return void 0;
22486
22515
  }
22487
- if (config.framework && config.framework in import_types.RUNTIME_BUILDERS) {
22488
- return config.framework;
22516
+ if (framework in import_types.RUNTIME_BUILDERS) {
22517
+ return framework;
22489
22518
  }
22490
- if ((0, import_framework_helpers.isPythonFramework)(config.framework)) {
22519
+ if ((0, import_framework_helpers.isPythonFramework)(framework)) {
22491
22520
  return "python";
22492
22521
  }
22493
- if ((0, import_framework_helpers.isBackendFramework)(config.framework)) {
22522
+ if ((0, import_framework_helpers.isBackendFramework)(framework)) {
22494
22523
  return "node";
22495
22524
  }
22525
+ return void 0;
22526
+ }
22527
+ function filterFrameworksByRuntime(frameworks2, runtime) {
22528
+ if (!runtime) {
22529
+ return [...frameworks2];
22530
+ }
22531
+ return frameworks2.filter(
22532
+ (framework) => inferRuntimeFromFramework(framework.slug) === runtime
22533
+ );
22534
+ }
22535
+ function inferServiceRuntime(config) {
22536
+ if (config.runtime && config.runtime in import_types.RUNTIME_BUILDERS) {
22537
+ return config.runtime;
22538
+ }
22539
+ const frameworkRuntime = inferRuntimeFromFramework(config.framework);
22540
+ if (frameworkRuntime) {
22541
+ return frameworkRuntime;
22542
+ }
22496
22543
  if (config.builder) {
22497
22544
  for (const [runtime, builderName] of Object.entries(import_types.RUNTIME_BUILDERS)) {
22498
22545
  if (config.builder === builderName) {
@@ -22914,12 +22961,14 @@ var require_resolve = __commonJS({
22914
22961
  async function detectFrameworkFromWorkspace({
22915
22962
  fs: fs5,
22916
22963
  workspace,
22917
- serviceName
22964
+ serviceName,
22965
+ runtime
22918
22966
  }) {
22919
22967
  const serviceFs = workspace === "." ? fs5 : fs5.chdir(workspace);
22968
+ const frameworkCandidates = (0, import_utils.filterFrameworksByRuntime)(import_frameworks2.default, runtime);
22920
22969
  const frameworks2 = await (0, import_detect_framework.detectFrameworks)({
22921
22970
  fs: serviceFs,
22922
- frameworkList: import_frameworks2.default
22971
+ frameworkList: frameworkCandidates
22923
22972
  });
22924
22973
  if (frameworks2.length > 1) {
22925
22974
  const frameworkNames = frameworks2.map((f) => f.name).join(", ");
@@ -23000,6 +23049,16 @@ var require_resolve = __commonJS({
23000
23049
  serviceName: name
23001
23050
  };
23002
23051
  }
23052
+ if (config.runtime && config.framework) {
23053
+ const frameworkRuntime = (0, import_utils.inferRuntimeFromFramework)(config.framework);
23054
+ if (frameworkRuntime && frameworkRuntime !== config.runtime) {
23055
+ return {
23056
+ code: "RUNTIME_FRAMEWORK_MISMATCH",
23057
+ message: `Service "${name}" has conflicting runtime/framework: runtime "${config.runtime}" is incompatible with framework "${config.framework}" (runtime "${frameworkRuntime}").`,
23058
+ serviceName: name
23059
+ };
23060
+ }
23061
+ }
23003
23062
  const hasFramework = Boolean(config.framework);
23004
23063
  const hasBuilderOrRuntime = Boolean(config.builder || config.runtime);
23005
23064
  const hasEntrypoint = Boolean(config.entrypoint);
@@ -23183,30 +23242,56 @@ var require_resolve = __commonJS({
23183
23242
  }
23184
23243
  }
23185
23244
  let resolvedConfig = serviceConfig;
23186
- const shouldDetectFramework = !serviceConfig.framework && Boolean(resolvedEntrypoint?.isDirectory);
23187
- if (shouldDetectFramework) {
23188
- const workspace = resolvedEntrypoint.normalized;
23189
- const { framework, error } = await detectFrameworkFromWorkspace({
23190
- fs: fs5,
23191
- workspace,
23192
- serviceName: name
23193
- });
23194
- if (error) {
23195
- errors.push(error);
23196
- continue;
23197
- }
23198
- if (!framework) {
23199
- errors.push({
23200
- code: "MISSING_SERVICE_FRAMEWORK",
23201
- message: `Service "${name}" uses directory entrypoint "${serviceConfig.entrypoint}" but no framework could be detected in "${workspace}". Specify "framework" explicitly or use a file entrypoint.`,
23245
+ if (!serviceConfig.framework && resolvedEntrypoint) {
23246
+ if (resolvedEntrypoint.isDirectory) {
23247
+ const workspace = resolvedEntrypoint.normalized;
23248
+ const { framework, error } = await detectFrameworkFromWorkspace({
23249
+ fs: fs5,
23250
+ workspace,
23202
23251
  serviceName: name
23203
23252
  });
23204
- continue;
23253
+ if (error) {
23254
+ errors.push(error);
23255
+ continue;
23256
+ }
23257
+ if (!framework) {
23258
+ errors.push({
23259
+ code: "MISSING_SERVICE_FRAMEWORK",
23260
+ message: `Service "${name}" uses directory entrypoint "${serviceConfig.entrypoint}" but no framework could be detected in "${workspace}". Specify "framework" explicitly or use a file entrypoint.`,
23261
+ serviceName: name
23262
+ });
23263
+ continue;
23264
+ }
23265
+ resolvedConfig = {
23266
+ ...resolvedConfig,
23267
+ framework
23268
+ };
23269
+ } else {
23270
+ const inferredRuntime = (0, import_utils.inferServiceRuntime)({
23271
+ ...serviceConfig,
23272
+ entrypoint: resolvedEntrypoint.normalized
23273
+ });
23274
+ if (inferredRuntime) {
23275
+ const inferredWorkspace = await inferWorkspaceFromNearestManifest({
23276
+ fs: fs5,
23277
+ entrypoint: resolvedEntrypoint.normalized,
23278
+ runtime: inferredRuntime
23279
+ });
23280
+ const workspace = inferredWorkspace ?? import_path7.posix.dirname(resolvedEntrypoint.normalized);
23281
+ const detection = await detectFrameworkFromWorkspace({
23282
+ fs: fs5,
23283
+ workspace,
23284
+ serviceName: name,
23285
+ runtime: inferredRuntime
23286
+ });
23287
+ if (detection.framework) {
23288
+ resolvedConfig = {
23289
+ ...resolvedConfig,
23290
+ framework: detection.framework
23291
+ };
23292
+ }
23293
+ }
23205
23294
  }
23206
- resolvedConfig = {
23207
- ...serviceConfig,
23208
- framework
23209
- };
23210
23295
  }
23211
23296
  const service = await resolveConfiguredService({
23212
23297
  name,
@@ -23354,6 +23439,9 @@ var require_auto_detect = __commonJS({
23354
23439
  if (backendResult.error) {
23355
23440
  return { services: null, errors: [backendResult.error] };
23356
23441
  }
23442
+ if (Object.keys(backendResult.services).length === 0) {
23443
+ return { services: null, errors: [] };
23444
+ }
23357
23445
  Object.assign(services, backendResult.services);
23358
23446
  return { services, errors: [] };
23359
23447
  }
@@ -23624,8 +23712,36 @@ var require_detect_services = __commonJS({
23624
23712
  continue;
23625
23713
  }
23626
23714
  }
23715
+ const workerServices = services.filter((s) => s.type === "worker");
23716
+ for (const service of workerServices) {
23717
+ const workerEntrypoint = service.entrypoint || service.builder.src || "index";
23718
+ const workerPath = (0, import_utils.getInternalServiceWorkerPath)(
23719
+ service.name,
23720
+ workerEntrypoint
23721
+ );
23722
+ const functionPath = (0, import_utils.getInternalServiceFunctionPath)(service.name);
23723
+ workers.push({
23724
+ src: `^${escapeRegex(workerPath)}$`,
23725
+ dest: functionPath,
23726
+ check: true
23727
+ });
23728
+ }
23729
+ const cronServices = services.filter((s) => s.type === "cron");
23730
+ for (const service of cronServices) {
23731
+ const cronEntrypoint = service.entrypoint || service.builder.src || "index";
23732
+ const cronPath = (0, import_utils.getInternalServiceCronPath)(service.name, cronEntrypoint);
23733
+ const functionPath = (0, import_utils.getInternalServiceFunctionPath)(service.name);
23734
+ crons.push({
23735
+ src: `^${escapeRegex(cronPath)}$`,
23736
+ dest: functionPath,
23737
+ check: true
23738
+ });
23739
+ }
23627
23740
  return { rewrites, defaults, crons, workers };
23628
23741
  }
23742
+ function escapeRegex(str) {
23743
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23744
+ }
23629
23745
  function getWebRoutePrefixes(services) {
23630
23746
  const unique = /* @__PURE__ */ new Set();
23631
23747
  for (const service of services) {
@@ -23925,7 +24041,11 @@ var require_get_services_builders = __commonJS({
23925
24041
  warnings: warningResponses,
23926
24042
  defaultRoutes: result.routes.defaults.length > 0 ? result.routes.defaults : null,
23927
24043
  redirectRoutes: [],
23928
- rewriteRoutes: result.routes.rewrites.length > 0 ? result.routes.rewrites : null,
24044
+ rewriteRoutes: result.routes.rewrites.length > 0 || result.routes.workers.length > 0 || result.routes.crons.length > 0 ? [
24045
+ ...result.routes.rewrites,
24046
+ ...result.routes.workers,
24047
+ ...result.routes.crons
24048
+ ] : null,
23929
24049
  errorRoutes: [],
23930
24050
  services: result.services
23931
24051
  };
@@ -24182,7 +24302,7 @@ var require_detect_builders = __commonJS({
24182
24302
  builders.push(...apiBuilders);
24183
24303
  }
24184
24304
  if (frontendBuilder) {
24185
- if (frontendBuilder?.use === "@vercel/express" || frontendBuilder?.use === "@vercel/hono" || frontendBuilder?.use === "@vercel/python" || frontendBuilder?.use === "@vercel/go") {
24305
+ if ((0, import_is_official_runtime.isOfficialRuntime)("express", frontendBuilder?.use) || (0, import_is_official_runtime.isOfficialRuntime)("hono", frontendBuilder?.use) || (0, import_is_official_runtime.isOfficialRuntime)("python", frontendBuilder?.use) || (0, import_is_official_runtime.isOfficialRuntime)("go", frontendBuilder?.use) || (0, import_is_official_runtime.isOfficialRuntime)("backends", frontendBuilder?.use)) {
24186
24306
  builders.push({
24187
24307
  src: "public/**/*",
24188
24308
  use: "@vercel/static",
@@ -24688,7 +24808,7 @@ var require_detect_builders = __commonJS({
24688
24808
  const hasApiBuild = apiBuilders.find((builder) => {
24689
24809
  return builder.src?.startsWith("api/");
24690
24810
  });
24691
- if (typeof ignoreRuntimes === "undefined" && hasApiBuild) {
24811
+ if (typeof ignoreRuntimes === "undefined" && hasApiBuild && !isNextjs) {
24692
24812
  rewriteRoutes.push({
24693
24813
  src: "^/api(/.*)?$",
24694
24814
  status: 404
@@ -24696,7 +24816,7 @@ var require_detect_builders = __commonJS({
24696
24816
  }
24697
24817
  } else {
24698
24818
  defaultRoutes.push(...apiRoutes);
24699
- if (apiRoutes.length) {
24819
+ if (apiRoutes.length && !isNextjs) {
24700
24820
  defaultRoutes.push({
24701
24821
  status: 404,
24702
24822
  src: "^/api(/.*)?$"
@@ -32191,7 +32311,11 @@ var require_dist7 = __commonJS({
32191
32311
  detectOutputDirectory: () => import_detect_builders.detectOutputDirectory,
32192
32312
  detectServices: () => import_detect_services.detectServices,
32193
32313
  generateServicesRoutes: () => import_detect_services.generateServicesRoutes,
32314
+ getInternalServiceCronPath: () => import_utils.getInternalServiceCronPath,
32315
+ getInternalServiceCronPathPrefix: () => import_utils.getInternalServiceCronPathPrefix,
32194
32316
  getInternalServiceFunctionPath: () => import_utils.getInternalServiceFunctionPath,
32317
+ getInternalServiceWorkerPath: () => import_utils.getInternalServiceWorkerPath,
32318
+ getInternalServiceWorkerPathPrefix: () => import_utils.getInternalServiceWorkerPathPrefix,
32195
32319
  getProjectPaths: () => import_get_project_paths.getProjectPaths,
32196
32320
  getServicesBuilders: () => import_get_services_builders.getServicesBuilders,
32197
32321
  getWorkspacePackagePaths: () => import_get_workspace_package_paths.getWorkspacePackagePaths,
@@ -32264,7 +32388,7 @@ async function readPackageJson(entryPath) {
32264
32388
  const packagePath = import_path.default.join(entryPath, "package.json");
32265
32389
  try {
32266
32390
  return JSON.parse(await import_fs.promises.readFile(packagePath, "utf8"));
32267
- } catch (err) {
32391
+ } catch (_err) {
32268
32392
  return {};
32269
32393
  }
32270
32394
  }
@@ -32528,7 +32652,7 @@ async function readBuildOutputDirectory2({
32528
32652
  const project = new import_ts_morph.Project();
32529
32653
  const config = (0, import_static_config.getConfig)(project, middleware.file.fsPath);
32530
32654
  return config?.regions;
32531
- } catch (err) {
32655
+ } catch (_err) {
32532
32656
  return void 0;
32533
32657
  }
32534
32658
  })()
@@ -33126,7 +33250,7 @@ function validateDistDir(distDir, workPath) {
33126
33250
  try {
33127
33251
  const vercelJson = JSON.parse((0, import_fs4.readFileSync)(vercelJsonPath, "utf8"));
33128
33252
  buildCommandExists = vercelJson.buildCommand !== void 0;
33129
- } catch (e) {
33253
+ } catch (_e) {
33130
33254
  }
33131
33255
  }
33132
33256
  let message = `No Output Directory named "${distDirName}" found after the Build completed.`;
@@ -33602,7 +33726,7 @@ var build = async ({
33602
33726
  nowDevChildProcesses.add(child);
33603
33727
  try {
33604
33728
  await checkForPort(devPort, DEV_SERVER_PORT_BIND_TIMEOUT);
33605
- } catch (err) {
33729
+ } catch (_err) {
33606
33730
  throw new Error(
33607
33731
  `Failed to detect a server running on port ${devPort}.
33608
33732
  Details: https://err.sh/vercel/vercel/now-static-build-failed-to-detect-a-server`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "2.8.43",
3
+ "version": "2.8.45",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -16,7 +16,7 @@
16
16
  "ts-morph": "12.0.0",
17
17
  "@vercel/gatsby-plugin-vercel-analytics": "1.0.11",
18
18
  "@vercel/static-config": "3.1.2",
19
- "@vercel/gatsby-plugin-vercel-builder": "2.0.141"
19
+ "@vercel/gatsby-plugin-vercel-builder": "2.0.143"
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.6.1",
41
+ "@vercel/build-utils": "13.6.3",
42
42
  "@vercel/error-utils": "2.0.3",
43
- "@vercel/fs-detectors": "5.8.12",
44
- "@vercel/routing-utils": "6.0.0",
45
- "@vercel/frameworks": "3.19.1"
43
+ "@vercel/frameworks": "3.20.0",
44
+ "@vercel/routing-utils": "6.0.2",
45
+ "@vercel/fs-detectors": "5.8.18"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "node ../../utils/build-builder.mjs",