@vercel/static-build 24.0.1 → 24.0.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 +81 -51
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -32388,6 +32388,7 @@ var require_detect_builders = __commonJS({
32388
32388
  DETECTION_FRAMEWORKS: () => DETECTION_FRAMEWORKS,
32389
32389
  filterFrameworksByRuntime: () => filterFrameworksByRuntime,
32390
32390
  frameworksBySlug: () => frameworksBySlug,
32391
+ getRuntimeFramework: () => getRuntimeFramework,
32391
32392
  inferBuilderRuntimeFromFramework: () => inferBuilderRuntimeFromFramework2,
32392
32393
  inferRuntimeFromFramework: () => inferRuntimeFromFramework,
32393
32394
  inferServerRuntimeFromFramework: () => inferServerRuntimeFromFramework,
@@ -32458,6 +32459,11 @@ var require_detect_builders = __commonJS({
32458
32459
  return [...frameworks2];
32459
32460
  return frameworks2.filter((f) => inferRuntimeFromFramework(f.slug) === runtime);
32460
32461
  }
32462
+ function getRuntimeFramework(runtime) {
32463
+ if (!runtime)
32464
+ return void 0;
32465
+ return frameworksBySlug.get(runtime)?.runtimeFramework ? runtime : void 0;
32466
+ }
32461
32467
  }
32462
32468
  });
32463
32469
  var detect_builders_exports = {};
@@ -32626,10 +32632,10 @@ var require_detect_builders = __commonJS({
32626
32632
  usedFunctions.add(key);
32627
32633
  };
32628
32634
  const absolutePathCache = /* @__PURE__ */ new Map();
32629
- const proxyFile = options.proxy ? parseProxyEntrypoint(options.proxy.entrypoint).file : null;
32635
+ const proxy = resolveProxy(files, options);
32630
32636
  const reservedFunctionFiles = options.reservedFunctionFiles ?? [];
32631
32637
  const claimedFiles = /* @__PURE__ */ new Set([
32632
- ...proxyFile !== null ? [proxyFile] : [],
32638
+ ...proxy?.source === "vercel-config" ? [proxy.file] : [],
32633
32639
  ...reservedFunctionFiles
32634
32640
  ]);
32635
32641
  const hasReservedFunctions = reservedFunctionFiles.length > 0;
@@ -32640,13 +32646,7 @@ var require_detect_builders = __commonJS({
32640
32646
  rustStaticOutput ? void 0 : frameworkConfig?.ignoreRuntimes
32641
32647
  );
32642
32648
  const withTag = options.tag ? `@${options.tag}` : "";
32643
- const apiMatches = getApiMatches().filter(
32644
- (b) => (
32645
- // Root-level middleware is enabled, unless `disableRootMiddleware: true`
32646
- b.config?.middleware && !frameworkConfig?.disableRootMiddleware || // "api" dir runtimes are enabled, unless opted-out via `ignoreRuntimes`
32647
- !ignoreRuntimes.has(b.use)
32648
- )
32649
- ).map((b) => {
32649
+ const apiMatches = getApiMatches().filter((b) => !ignoreRuntimes.has(b.use)).map((b) => {
32650
32650
  b.use = `${b.use}${withTag}`;
32651
32651
  return b;
32652
32652
  });
@@ -32662,8 +32662,8 @@ var require_detect_builders = __commonJS({
32662
32662
  if (claimedFiles.has(fileName)) {
32663
32663
  continue;
32664
32664
  }
32665
- const apiBuilder = await maybeGetApiBuilder(fileName, apiMatches, options);
32666
- if (apiBuilder) {
32665
+ const functionBuilder = proxy?.source === "file-convention" && fileName === proxy.file ? proxy.builder : await maybeGetApiBuilder(fileName, apiMatches, options);
32666
+ if (functionBuilder) {
32667
32667
  const { routeError, apiRoute, isDynamic } = getApiRoute(
32668
32668
  fileName,
32669
32669
  apiSortedFiles,
@@ -32687,8 +32687,8 @@ var require_detect_builders = __commonJS({
32687
32687
  dynamicRoutes.push(apiRoute);
32688
32688
  }
32689
32689
  }
32690
- addToUsedFunctions(apiBuilder);
32691
- apiBuilders.push(apiBuilder);
32690
+ addToUsedFunctions(functionBuilder);
32691
+ apiBuilders.push(functionBuilder);
32692
32692
  continue;
32693
32693
  }
32694
32694
  if (!hasUsedOutputDirectory && fileName.startsWith(`${usedOutputDirectory}/`)) {
@@ -32704,14 +32704,9 @@ var require_detect_builders = __commonJS({
32704
32704
  fallbackEntrypoint = fileName;
32705
32705
  }
32706
32706
  }
32707
- if (options.proxy) {
32708
- const proxyBuilder = getProxyBuilder2(
32709
- options.proxy,
32710
- options.tag,
32711
- options.functions
32712
- );
32713
- addToUsedFunctions(proxyBuilder);
32714
- apiBuilders.unshift(proxyBuilder);
32707
+ if (proxy?.source === "vercel-config") {
32708
+ addToUsedFunctions(proxy.builder);
32709
+ apiBuilders.unshift(proxy.builder);
32715
32710
  }
32716
32711
  const rustStaticPrebuilt = rustStaticOutput && !pkg && !buildCommand;
32717
32712
  if (!makeFrontendStatic && !rustStaticPrebuilt && (hasBuildScript(pkg) || buildCommand || framework)) {
@@ -32856,11 +32851,7 @@ var require_detect_builders = __commonJS({
32856
32851
  };
32857
32852
  }
32858
32853
  async function maybeGetApiBuilder(fileName, apiMatches, options) {
32859
- const middleware = !options.proxy && (fileName === "middleware.js" || fileName === "middleware.ts");
32860
- if (middleware && options.projectSettings?.framework === "nextjs") {
32861
- return null;
32862
- }
32863
- if (!(fileName.startsWith("api/") || middleware)) {
32854
+ if (!fileName.startsWith("api/")) {
32864
32855
  return null;
32865
32856
  }
32866
32857
  if (fileName.includes("/.")) {
@@ -32898,10 +32889,15 @@ var require_detect_builders = __commonJS({
32898
32889
  if (!use) {
32899
32890
  return null;
32900
32891
  }
32892
+ const builder = {
32893
+ use,
32894
+ src: fileName,
32895
+ config: getFunctionConfig(fnPattern, func, options)
32896
+ };
32897
+ return builder;
32898
+ }
32899
+ function getFunctionConfig(fnPattern, func, options) {
32901
32900
  const config = { zeroConfig: true };
32902
- if (middleware) {
32903
- config.middleware = true;
32904
- }
32905
32901
  if (fnPattern && func) {
32906
32902
  config.functions = { [fnPattern]: func };
32907
32903
  if (func.includeFiles) {
@@ -32914,12 +32910,7 @@ var require_detect_builders = __commonJS({
32914
32910
  if (options.bunVersion) {
32915
32911
  config.bunVersion = options.bunVersion;
32916
32912
  }
32917
- const builder = {
32918
- use,
32919
- src: fileName,
32920
- config
32921
- };
32922
- return builder;
32913
+ return config;
32923
32914
  }
32924
32915
  function getFunction(fileName, { functions = {} }) {
32925
32916
  const keys = Object.keys(functions);
@@ -32937,6 +32928,44 @@ var require_detect_builders = __commonJS({
32937
32928
  }
32938
32929
  return { file: entrypoint };
32939
32930
  }
32931
+ var ROOT_PROXY_FILES = ["middleware.js", "middleware.ts"];
32932
+ function resolveProxy(files, options) {
32933
+ const { proxy } = options;
32934
+ if (proxy) {
32935
+ return {
32936
+ source: "vercel-config",
32937
+ entrypoint: proxy.entrypoint,
32938
+ file: parseProxyEntrypoint(proxy.entrypoint).file,
32939
+ builder: getProxyBuilder2(proxy, options.tag, options.functions)
32940
+ };
32941
+ }
32942
+ const framework = options.projectSettings?.framework;
32943
+ if (framework === "nextjs" || import_framework.frameworksBySlug.get(framework || "")?.disableRootMiddleware) {
32944
+ return null;
32945
+ }
32946
+ const reserved = new Set(options.reservedFunctionFiles ?? []);
32947
+ const file = ROOT_PROXY_FILES.find(
32948
+ (f) => files.includes(f) && !reserved.has(f)
32949
+ );
32950
+ if (!file) {
32951
+ return null;
32952
+ }
32953
+ const { fnPattern, func } = getFunction(file, options);
32954
+ const withTag = options.tag ? `@${options.tag}` : "";
32955
+ return {
32956
+ source: "file-convention",
32957
+ entrypoint: null,
32958
+ file,
32959
+ builder: {
32960
+ use: func?.runtime || `@vercel/node${withTag}`,
32961
+ src: file,
32962
+ config: {
32963
+ ...getFunctionConfig(fnPattern, func, options),
32964
+ middleware: true
32965
+ }
32966
+ }
32967
+ };
32968
+ }
32940
32969
  function getProxyBuilder2(proxy, tag, functions = {}) {
32941
32970
  const { file, variable } = parseProxyEntrypoint(proxy.entrypoint);
32942
32971
  const isPython = (0, import_path7.extname)(file) === ".py";
@@ -32968,11 +32997,6 @@ var require_detect_builders = __commonJS({
32968
32997
  function getApiMatches() {
32969
32998
  const config = { zeroConfig: true };
32970
32999
  return [
32971
- {
32972
- src: REGEX_MIDDLEWARE_FILES,
32973
- use: `@vercel/node`,
32974
- config: { ...config, middleware: true }
32975
- },
32976
33000
  { src: "api/**/*.+(js|mjs|ts|tsx)", use: `@vercel/node`, config },
32977
33001
  { src: "api/**/!(*_test).go", use: `@vercel/go`, config },
32978
33002
  { src: "api/**/*.py", use: `@vercel/python`, config },
@@ -50196,19 +50220,19 @@ function getFramework(config, pkg) {
50196
50220
  }
50197
50221
  const { framework: configFramework = null } = config || {};
50198
50222
  if (configFramework) {
50199
- const framework2 = import_frameworks.frameworkList.find(({ slug }) => slug === configFramework);
50200
- if (framework2) {
50201
- return framework2;
50223
+ const framework = import_frameworks.frameworkList.find(({ slug }) => slug === configFramework);
50224
+ if (framework) {
50225
+ return framework;
50202
50226
  }
50203
50227
  }
50228
+ return detectFrameworkFromDependencies(pkg);
50229
+ }
50230
+ function detectFrameworkFromDependencies(pkg) {
50204
50231
  if (!pkg) {
50205
50232
  return;
50206
50233
  }
50207
50234
  const dependencies = Object.assign({}, pkg.dependencies, pkg.devDependencies);
50208
- const framework = import_frameworks.frameworkList.find(
50209
- ({ dependency }) => dependencies[dependency || ""]
50210
- );
50211
- return framework;
50235
+ return import_frameworks.frameworkList.find(({ dependency }) => dependencies[dependency || ""]);
50212
50236
  }
50213
50237
  async function fetchBinary(url, framework, version2, dest = "/usr/local/bin") {
50214
50238
  const res = await (0, import_node_fetch2.default)(url);
@@ -50251,6 +50275,7 @@ var build = async ({
50251
50275
  config,
50252
50276
  meta = {},
50253
50277
  service,
50278
+ diagnosticsValues,
50254
50279
  span
50255
50280
  }) => {
50256
50281
  await (0, import_build_utils4.download)(files, workPath, meta);
@@ -50526,7 +50551,9 @@ var build = async ({
50526
50551
  }
50527
50552
  await generateStaticBuildManifest({
50528
50553
  framework,
50554
+ detectedFramework: detectFrameworkFromDependencies(pkg),
50529
50555
  service,
50556
+ diagnosticsValues,
50530
50557
  entrypointDir,
50531
50558
  nodeVersion,
50532
50559
  cliType,
@@ -50767,13 +50794,16 @@ var prepareCache = async ({
50767
50794
  var STATIC_BUILD_MANIFEST_RUNTIME = "static-build";
50768
50795
  async function generateStaticBuildManifest({
50769
50796
  framework,
50797
+ detectedFramework,
50770
50798
  service,
50799
+ diagnosticsValues,
50771
50800
  entrypointDir,
50772
50801
  nodeVersion,
50773
50802
  cliType,
50774
50803
  lockfilePath,
50775
50804
  lockfileVersion
50776
50805
  }) {
50806
+ const reportedFramework = diagnosticsValues?.framework ?? detectedFramework?.slug ?? void 0;
50777
50807
  if (framework?.slug === "hugo") {
50778
50808
  try {
50779
50809
  const hugoVersionOut = (0, import_child_process.spawnSync)("hugo", ["version"], {
@@ -50784,7 +50814,7 @@ async function generateStaticBuildManifest({
50784
50814
  {
50785
50815
  version: import_build_utils4.MANIFEST_VERSION,
50786
50816
  runtime: "go",
50787
- framework: framework.slug,
50817
+ framework: reportedFramework,
50788
50818
  serviceType: service ? (0, import_build_utils4.getReportedServiceType)(service) : void 0,
50789
50819
  dependencies: [
50790
50820
  {
@@ -50813,7 +50843,7 @@ async function generateStaticBuildManifest({
50813
50843
  {
50814
50844
  version: import_build_utils4.MANIFEST_VERSION,
50815
50845
  runtime: "rust",
50816
- framework: framework.slug,
50846
+ framework: reportedFramework,
50817
50847
  serviceType: service ? (0, import_build_utils4.getReportedServiceType)(service) : void 0,
50818
50848
  dependencies: [
50819
50849
  {
@@ -50836,7 +50866,7 @@ async function generateStaticBuildManifest({
50836
50866
  await (0, import_build_utils4.generateRubyProjectManifest)({
50837
50867
  workPath: entrypointDir,
50838
50868
  gemfileLockPath: import_path6.default.join(entrypointDir, "Gemfile.lock"),
50839
- framework: framework.slug,
50869
+ framework: reportedFramework,
50840
50870
  serviceType: service ? (0, import_build_utils4.getReportedServiceType)(service) : void 0,
50841
50871
  outputRuntime: STATIC_BUILD_MANIFEST_RUNTIME
50842
50872
  });
@@ -50848,7 +50878,7 @@ async function generateStaticBuildManifest({
50848
50878
  cliType,
50849
50879
  lockfilePath,
50850
50880
  lockfileVersion,
50851
- framework: framework.slug,
50881
+ framework: reportedFramework,
50852
50882
  serviceType: service ? (0, import_build_utils4.getReportedServiceType)(service) : void 0,
50853
50883
  outputRuntime: STATIC_BUILD_MANIFEST_RUNTIME
50854
50884
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "24.0.1",
3
+ "version": "24.0.2",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -16,10 +16,10 @@
16
16
  "ts-morph": "12.0.0",
17
17
  "@vercel/gatsby-plugin-vercel-analytics": "1.0.12",
18
18
  "@vercel/static-config": "3.4.4",
19
- "@vercel/gatsby-plugin-vercel-builder": "2.2.79"
19
+ "@vercel/gatsby-plugin-vercel-builder": "2.2.80"
20
20
  },
21
21
  "peerDependencies": {
22
- "@vercel/build-utils": "15.0.1"
22
+ "@vercel/build-utils": "15.0.2"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/aws-lambda": "8.10.64",
@@ -40,11 +40,11 @@
40
40
  "semver": "7.5.2",
41
41
  "tree-kill": "1.2.2",
42
42
  "vitest": "4.1.10",
43
+ "@vercel/build-utils": "15.0.2",
43
44
  "@vercel/error-utils": "2.2.1",
44
- "@vercel/build-utils": "15.0.1",
45
- "@vercel/fs-detectors": "7.10.2",
46
45
  "@vercel/frameworks": "3.35.0",
47
- "@vercel/routing-utils": "6.6.0"
46
+ "@vercel/routing-utils": "6.6.0",
47
+ "@vercel/fs-detectors": "7.11.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "node ../../utils/build-builder.mjs",