@vercel/build-utils 2.12.3-canary.34 → 2.12.3-canary.38

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.
@@ -79,6 +79,8 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
79
79
  await fs_extra_1.default.ensureDir(traceDir);
80
80
  let newPathsRuntime = new Set();
81
81
  let linkersRuntime = [];
82
+ const entryDir = path_1.join('.output', 'server', 'pages');
83
+ const entryRoot = path_1.join(workPath, entryDir);
82
84
  for (const entrypoint of Object.keys(entrypoints)) {
83
85
  const { output } = await buildRuntime({
84
86
  files: sourceFilesPreBuild,
@@ -89,6 +91,7 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
89
91
  },
90
92
  meta: {
91
93
  avoidTopLevelInstall: true,
94
+ skipDownload: true,
92
95
  },
93
96
  });
94
97
  // Legacy Runtimes tend to pollute the `workPath` with compiled results,
@@ -98,14 +101,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
98
101
  // so we don't want to pollute this space unnecessarily. That means we have to clean
99
102
  // up files that were created by the build, which is done further below.
100
103
  const sourceFilesAfterBuild = await getSourceFiles(workPath, ignoreFilter);
101
- // Further down, we will need the filename of the Lambda handler
102
- // for placing it inside `server/pages/api`, but because Legacy Runtimes
103
- // don't expose the filename directly, we have to construct it
104
- // from the handler name, and then find the matching file further below,
105
- // because we don't yet know its extension here.
106
- const handler = output.handler;
107
- const handlerMethod = handler.split('.').reverse()[0];
108
- const handlerFileName = handler.replace(`.${handlerMethod}`, '');
109
104
  // @ts-ignore This symbol is a private API
110
105
  const lambdaFiles = output[lambda_1.FILES_SYMBOL];
111
106
  // When deploying, the `files` that are passed to the Legacy Runtimes already
@@ -117,20 +112,33 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
117
112
  delete lambdaFiles[file];
118
113
  }
119
114
  }
120
- const handlerFilePath = Object.keys(lambdaFiles).find(item => {
121
- return path_1.parse(item).name === handlerFileName;
122
- });
123
- const handlerFileOrigin = lambdaFiles[handlerFilePath || ''].fsPath;
124
- if (!handlerFileOrigin) {
125
- throw new Error(`Could not find a handler file. Please ensure that the list of \`files\` defined for the returned \`Lambda\` contains a file with the name ${handlerFileName} (+ any extension).`);
115
+ let handlerFileBase = output.handler;
116
+ let handlerFile = lambdaFiles[handlerFileBase];
117
+ const { handler } = output;
118
+ const handlerMethod = handler.split('.').pop();
119
+ const handlerFileName = handler.replace(`.${handlerMethod}`, '');
120
+ // For compiled languages, the launcher file for the Lambda generated
121
+ // by the Legacy Runtime matches the `handler` defined for it, but for
122
+ // interpreted languages, the `handler` consists of the launcher file name
123
+ // without an extension, plus the name of the method inside of that file
124
+ // that should be invoked, so we have to construct the file path explicitly.
125
+ if (!handlerFile) {
126
+ handlerFileBase = handlerFileName + ext;
127
+ handlerFile = lambdaFiles[handlerFileBase];
128
+ }
129
+ if (!handlerFile || !handlerFile.fsPath) {
130
+ 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\`.`);
126
131
  }
127
- const entry = path_1.join(workPath, '.output', 'server', 'pages', entrypoint);
132
+ const handlerExtName = path_1.extname(handlerFile.fsPath);
133
+ const entryBase = path_1.basename(entrypoint).replace(ext, handlerExtName);
134
+ const entryPath = path_1.join(path_1.dirname(entrypoint), entryBase);
135
+ const entry = path_1.join(entryRoot, entryPath);
128
136
  // We never want to link here, only copy, because the launcher
129
137
  // file often has the same name for every entrypoint, which means that
130
138
  // every build for every entrypoint overwrites the launcher of the previous
131
139
  // one, so linking would end with a broken reference.
132
140
  await fs_extra_1.default.ensureDir(path_1.dirname(entry));
133
- await fs_extra_1.default.copy(handlerFileOrigin, entry);
141
+ await fs_extra_1.default.copy(handlerFile.fsPath, entry);
134
142
  const newFilesEntrypoint = [];
135
143
  const newDirectoriesEntrypoint = [];
136
144
  const preBuildFiles = Object.values(sourceFilesPreBuild).map(file => {
@@ -181,7 +189,7 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
181
189
  const linkers = Object.entries(lambdaFiles).map(async ([relPath, file]) => {
182
190
  const newPath = path_1.join(traceDir, relPath);
183
191
  // The handler was already moved into position above.
184
- if (relPath === handlerFilePath) {
192
+ if (relPath === handlerFileBase) {
185
193
  return;
186
194
  }
187
195
  tracedFiles.push({ absolutePath: newPath, relativePath: relPath });
@@ -218,12 +226,14 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
218
226
  }
219
227
  });
220
228
  linkersRuntime = linkersRuntime.concat(linkers);
221
- const nft = path_1.join(workPath, '.output', 'server', 'pages', `${entrypoint}.nft.json`);
229
+ const nft = `${entry}.nft.json`;
222
230
  const json = JSON.stringify({
223
231
  version: 1,
224
232
  files: tracedFiles.map(file => ({
225
233
  input: normalize_path_1.normalizePath(path_1.relative(path_1.dirname(nft), file.absolutePath)),
226
- output: normalize_path_1.normalizePath(file.relativePath),
234
+ // We'd like to place all the dependency files right next
235
+ // to the final launcher file inside of the Lambda.
236
+ output: normalize_path_1.normalizePath(path_1.join(entryDir, 'api', file.relativePath)),
227
237
  })),
228
238
  });
229
239
  await fs_extra_1.default.ensureDir(path_1.dirname(nft));
@@ -236,11 +246,14 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
236
246
  ...newFilesEntrypoint,
237
247
  ...newDirectoriesEntrypoint,
238
248
  ]);
239
- const apiRouteHandler = `${path_1.parse(entry).name}.${handlerMethod}`;
240
249
  // Add an entry that will later on be added to the `functions-manifest.json`
241
250
  // file that is placed inside of the `.output` directory.
242
- pages[entrypoint] = {
243
- handler: apiRouteHandler,
251
+ pages[normalize_path_1.normalizePath(entryPath)] = {
252
+ // Because the underlying file used as a handler was placed
253
+ // inside `.output/server/pages/api`, it no longer has the name it originally
254
+ // had and is now named after the API Route that it's responsible for,
255
+ // so we have to adjust the name of the Lambda handler accordingly.
256
+ handler: handler.replace(handlerFileName, path_1.parse(entry).name),
244
257
  runtime: output.runtime,
245
258
  memory: output.memory,
246
259
  maxDuration: output.maxDuration,
package/dist/index.js CHANGED
@@ -26693,7 +26693,6 @@ exports.frameworks = [
26693
26693
  },
26694
26694
  dependency: 'gatsby',
26695
26695
  getOutputDirName: async () => 'public',
26696
- getFsOutputDir: async () => 'public',
26697
26696
  defaultRoutes: async (dirPrefix) => {
26698
26697
  // This file could be generated by gatsby-plugin-now or gatsby-plugin-zeit-now
26699
26698
  try {
@@ -26774,7 +26773,6 @@ exports.frameworks = [
26774
26773
  },
26775
26774
  },
26776
26775
  dependency: 'remix',
26777
- getFsOutputDir: async () => 'public',
26778
26776
  getOutputDirName: async () => 'public',
26779
26777
  defaultRoutes: [
26780
26778
  {
@@ -26802,10 +26800,13 @@ exports.frameworks = [
26802
26800
  source: '/build/(.*)',
26803
26801
  regex: '/build/(.*)',
26804
26802
  headers: [
26805
- { key: 'cache-control', value: 'public, max-age=31536000, immutable' },
26803
+ {
26804
+ key: 'cache-control',
26805
+ value: 'public, max-age=31536000, immutable',
26806
+ },
26806
26807
  ],
26807
26808
  },
26808
- ]
26809
+ ],
26809
26810
  },
26810
26811
  {
26811
26812
  name: 'Hexo',
@@ -26840,7 +26841,6 @@ exports.frameworks = [
26840
26841
  },
26841
26842
  },
26842
26843
  dependency: 'hexo',
26843
- getFsOutputDir: async () => 'public',
26844
26844
  getOutputDirName: async () => 'public',
26845
26845
  },
26846
26846
  {
@@ -26876,7 +26876,6 @@ exports.frameworks = [
26876
26876
  },
26877
26877
  },
26878
26878
  dependency: '@11ty/eleventy',
26879
- getFsOutputDir: async () => '_site',
26880
26879
  getOutputDirName: async () => '_site',
26881
26880
  cachePattern: '.cache/**',
26882
26881
  },
@@ -26913,21 +26912,6 @@ exports.frameworks = [
26913
26912
  },
26914
26913
  },
26915
26914
  dependency: '@docusaurus/core',
26916
- getFsOutputDir: async (dirPrefix) => {
26917
- const base = 'build';
26918
- try {
26919
- const location = path_1.join(dirPrefix, base);
26920
- const content = await readdir(location, { withFileTypes: true });
26921
- // If there is only one file in it that is a dir we'll use it as dist dir
26922
- if (content.length === 1 && content[0].isDirectory()) {
26923
- return path_1.join(base, content[0].name);
26924
- }
26925
- }
26926
- catch (error) {
26927
- console.error(`Error detecting output directory: `, error);
26928
- }
26929
- return base;
26930
- },
26931
26915
  getOutputDirName: async (dirPrefix) => {
26932
26916
  const base = 'build';
26933
26917
  try {
@@ -27057,21 +27041,6 @@ exports.frameworks = [
27057
27041
  },
27058
27042
  },
27059
27043
  dependency: 'docusaurus',
27060
- getFsOutputDir: async (dirPrefix) => {
27061
- const base = 'build';
27062
- try {
27063
- const location = path_1.join(dirPrefix, base);
27064
- const content = await readdir(location, { withFileTypes: true });
27065
- // If there is only one file in it that is a dir we'll use it as dist dir
27066
- if (content.length === 1 && content[0].isDirectory()) {
27067
- return path_1.join(base, content[0].name);
27068
- }
27069
- }
27070
- catch (error) {
27071
- console.error(`Error detecting output directory: `, error);
27072
- }
27073
- return base;
27074
- },
27075
27044
  getOutputDirName: async (dirPrefix) => {
27076
27045
  const base = 'build';
27077
27046
  try {
@@ -27121,7 +27090,6 @@ exports.frameworks = [
27121
27090
  },
27122
27091
  },
27123
27092
  dependency: 'preact-cli',
27124
- getFsOutputDir: async () => 'build',
27125
27093
  getOutputDirName: async () => 'build',
27126
27094
  defaultRoutes: [
27127
27095
  {
@@ -27176,7 +27144,6 @@ exports.frameworks = [
27176
27144
  },
27177
27145
  },
27178
27146
  dependency: '@dojo/cli',
27179
- getFsOutputDir: async () => 'output/dist',
27180
27147
  getOutputDirName: async () => path_1.join('output', 'dist'),
27181
27148
  defaultRoutes: [
27182
27149
  {
@@ -27241,7 +27208,6 @@ exports.frameworks = [
27241
27208
  },
27242
27209
  },
27243
27210
  dependency: 'ember-cli',
27244
- getFsOutputDir: async () => 'dist',
27245
27211
  getOutputDirName: async () => 'dist',
27246
27212
  defaultRoutes: [
27247
27213
  {
@@ -27294,7 +27260,6 @@ exports.frameworks = [
27294
27260
  },
27295
27261
  },
27296
27262
  dependency: '@vue/cli-service',
27297
- getFsOutputDir: async () => 'dist',
27298
27263
  getOutputDirName: async () => 'dist',
27299
27264
  defaultRoutes: [
27300
27265
  {
@@ -27370,7 +27335,6 @@ exports.frameworks = [
27370
27335
  },
27371
27336
  },
27372
27337
  dependency: '@scullyio/init',
27373
- getFsOutputDir: async () => 'dist',
27374
27338
  getOutputDirName: async () => 'dist/static',
27375
27339
  },
27376
27340
  {
@@ -27405,7 +27369,6 @@ exports.frameworks = [
27405
27369
  },
27406
27370
  },
27407
27371
  dependency: '@ionic/angular',
27408
- getFsOutputDir: async () => 'www',
27409
27372
  getOutputDirName: async () => 'www',
27410
27373
  defaultRoutes: [
27411
27374
  {
@@ -27457,7 +27420,6 @@ exports.frameworks = [
27457
27420
  },
27458
27421
  },
27459
27422
  dependency: '@angular/cli',
27460
- getFsOutputDir: async () => 'dist',
27461
27423
  getOutputDirName: async (dirPrefix) => {
27462
27424
  const base = 'dist';
27463
27425
  try {
@@ -27523,7 +27485,6 @@ exports.frameworks = [
27523
27485
  },
27524
27486
  },
27525
27487
  dependency: 'polymer-cli',
27526
- getFsOutputDir: async () => 'build',
27527
27488
  getOutputDirName: async (dirPrefix) => {
27528
27489
  const base = 'build';
27529
27490
  try {
@@ -27591,7 +27552,6 @@ exports.frameworks = [
27591
27552
  },
27592
27553
  },
27593
27554
  dependency: 'sirv-cli',
27594
- getFsOutputDir: async () => 'public',
27595
27555
  getOutputDirName: async () => 'public',
27596
27556
  defaultRoutes: [
27597
27557
  {
@@ -27639,10 +27599,9 @@ exports.frameworks = [
27639
27599
  placeholder: 'svelte-kit dev',
27640
27600
  },
27641
27601
  outputDirectory: {
27642
- placeholder: 'public',
27602
+ value: 'public',
27643
27603
  },
27644
27604
  },
27645
- getFsOutputDir: async () => '.output',
27646
27605
  getOutputDirName: async () => 'public',
27647
27606
  },
27648
27607
  {
@@ -27677,7 +27636,6 @@ exports.frameworks = [
27677
27636
  },
27678
27637
  },
27679
27638
  dependency: '@ionic/react',
27680
- getFsOutputDir: async () => 'build',
27681
27639
  getOutputDirName: async () => 'build',
27682
27640
  defaultRoutes: [
27683
27641
  {
@@ -27782,7 +27740,6 @@ exports.frameworks = [
27782
27740
  },
27783
27741
  },
27784
27742
  dependency: 'react-scripts',
27785
- getFsOutputDir: async () => 'build',
27786
27743
  getOutputDirName: async () => 'build',
27787
27744
  defaultRoutes: [
27788
27745
  {
@@ -27882,7 +27839,6 @@ exports.frameworks = [
27882
27839
  },
27883
27840
  },
27884
27841
  dependency: 'gridsome',
27885
- getFsOutputDir: async () => 'dist',
27886
27842
  getOutputDirName: async () => 'dist',
27887
27843
  },
27888
27844
  {
@@ -27918,7 +27874,6 @@ exports.frameworks = [
27918
27874
  },
27919
27875
  },
27920
27876
  dependency: 'umi',
27921
- getFsOutputDir: async () => 'dist',
27922
27877
  getOutputDirName: async () => 'dist',
27923
27878
  defaultRoutes: [
27924
27879
  {
@@ -27970,7 +27925,6 @@ exports.frameworks = [
27970
27925
  },
27971
27926
  },
27972
27927
  dependency: 'sapper',
27973
- getFsOutputDir: async () => '__sapper__/export',
27974
27928
  getOutputDirName: async () => '__sapper__/export',
27975
27929
  },
27976
27930
  {
@@ -28006,7 +27960,6 @@ exports.frameworks = [
28006
27960
  },
28007
27961
  },
28008
27962
  dependency: 'saber',
28009
- getFsOutputDir: async () => 'public',
28010
27963
  getOutputDirName: async () => 'public',
28011
27964
  defaultRoutes: [
28012
27965
  {
@@ -28073,7 +28026,6 @@ exports.frameworks = [
28073
28026
  },
28074
28027
  },
28075
28028
  dependency: '@stencil/core',
28076
- getFsOutputDir: async () => 'www',
28077
28029
  getOutputDirName: async () => 'www',
28078
28030
  defaultRoutes: [
28079
28031
  {
@@ -28160,7 +28112,6 @@ exports.frameworks = [
28160
28112
  },
28161
28113
  },
28162
28114
  dependency: 'nuxt',
28163
- getFsOutputDir: async () => '.output',
28164
28115
  getOutputDirName: async () => 'dist',
28165
28116
  cachePattern: '.nuxt/**',
28166
28117
  defaultRoutes: [
@@ -28217,7 +28168,6 @@ exports.frameworks = [
28217
28168
  placeholder: 'RedwoodJS default',
28218
28169
  },
28219
28170
  },
28220
- getFsOutputDir: async () => 'public',
28221
28171
  getOutputDirName: async () => 'public',
28222
28172
  },
28223
28173
  {
@@ -28260,12 +28210,6 @@ exports.frameworks = [
28260
28210
  placeholder: '`public` or `publishDir` from the `config` file',
28261
28211
  },
28262
28212
  },
28263
- getFsOutputDir: async (dirPrefix) => {
28264
- const config = await read_config_file_1.readConfigFile(['config.json', 'config.yaml', 'config.toml'].map(fileName => {
28265
- return path_1.join(dirPrefix, fileName);
28266
- }));
28267
- return (config && config.publishDir) || 'public';
28268
- },
28269
28213
  getOutputDirName: async (dirPrefix) => {
28270
28214
  const config = await read_config_file_1.readConfigFile(['config.json', 'config.yaml', 'config.toml'].map(fileName => {
28271
28215
  return path_1.join(dirPrefix, fileName);
@@ -28305,10 +28249,6 @@ exports.frameworks = [
28305
28249
  placeholder: '`_site` or `destination` from `_config.yml`',
28306
28250
  },
28307
28251
  },
28308
- getFsOutputDir: async (dirPrefix) => {
28309
- const config = await read_config_file_1.readConfigFile(path_1.join(dirPrefix, '_config.yml'));
28310
- return (config && config.destination) || '_site';
28311
- },
28312
28252
  getOutputDirName: async (dirPrefix) => {
28313
28253
  const config = await read_config_file_1.readConfigFile(path_1.join(dirPrefix, '_config.yml'));
28314
28254
  return (config && config.destination) || '_site';
@@ -28346,7 +28286,6 @@ exports.frameworks = [
28346
28286
  value: 'public',
28347
28287
  },
28348
28288
  },
28349
- getFsOutputDir: async () => 'public',
28350
28289
  getOutputDirName: async () => 'public',
28351
28290
  },
28352
28291
  {
@@ -28380,7 +28319,6 @@ exports.frameworks = [
28380
28319
  value: 'build',
28381
28320
  },
28382
28321
  },
28383
- getFsOutputDir: async () => 'build',
28384
28322
  getOutputDirName: async () => 'build',
28385
28323
  cachePattern: '{vendor/bin,vendor/cache,vendor/bundle}/**',
28386
28324
  },
@@ -28415,7 +28353,6 @@ exports.frameworks = [
28415
28353
  value: 'public',
28416
28354
  },
28417
28355
  },
28418
- getFsOutputDir: async () => 'public',
28419
28356
  getOutputDirName: async () => 'public',
28420
28357
  defaultVersion: '0.13.0',
28421
28358
  },
@@ -28453,7 +28390,6 @@ exports.frameworks = [
28453
28390
  },
28454
28391
  },
28455
28392
  dependency: 'vite',
28456
- getFsOutputDir: async () => 'dist',
28457
28393
  getOutputDirName: async () => 'dist',
28458
28394
  },
28459
28395
  {
@@ -28489,7 +28425,6 @@ exports.frameworks = [
28489
28425
  },
28490
28426
  },
28491
28427
  dependency: 'parcel',
28492
- getFsOutputDir: async () => 'dist',
28493
28428
  getOutputDirName: async () => 'dist',
28494
28429
  defaultRoutes: [
28495
28430
  {
@@ -32826,6 +32761,8 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32826
32761
  await fs_extra_1.default.ensureDir(traceDir);
32827
32762
  let newPathsRuntime = new Set();
32828
32763
  let linkersRuntime = [];
32764
+ const entryDir = path_1.join('.output', 'server', 'pages');
32765
+ const entryRoot = path_1.join(workPath, entryDir);
32829
32766
  for (const entrypoint of Object.keys(entrypoints)) {
32830
32767
  const { output } = await buildRuntime({
32831
32768
  files: sourceFilesPreBuild,
@@ -32836,6 +32773,7 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32836
32773
  },
32837
32774
  meta: {
32838
32775
  avoidTopLevelInstall: true,
32776
+ skipDownload: true,
32839
32777
  },
32840
32778
  });
32841
32779
  // Legacy Runtimes tend to pollute the `workPath` with compiled results,
@@ -32845,14 +32783,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32845
32783
  // so we don't want to pollute this space unnecessarily. That means we have to clean
32846
32784
  // up files that were created by the build, which is done further below.
32847
32785
  const sourceFilesAfterBuild = await getSourceFiles(workPath, ignoreFilter);
32848
- // Further down, we will need the filename of the Lambda handler
32849
- // for placing it inside `server/pages/api`, but because Legacy Runtimes
32850
- // don't expose the filename directly, we have to construct it
32851
- // from the handler name, and then find the matching file further below,
32852
- // because we don't yet know its extension here.
32853
- const handler = output.handler;
32854
- const handlerMethod = handler.split('.').reverse()[0];
32855
- const handlerFileName = handler.replace(`.${handlerMethod}`, '');
32856
32786
  // @ts-ignore This symbol is a private API
32857
32787
  const lambdaFiles = output[lambda_1.FILES_SYMBOL];
32858
32788
  // When deploying, the `files` that are passed to the Legacy Runtimes already
@@ -32864,20 +32794,33 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32864
32794
  delete lambdaFiles[file];
32865
32795
  }
32866
32796
  }
32867
- const handlerFilePath = Object.keys(lambdaFiles).find(item => {
32868
- return path_1.parse(item).name === handlerFileName;
32869
- });
32870
- const handlerFileOrigin = lambdaFiles[handlerFilePath || ''].fsPath;
32871
- if (!handlerFileOrigin) {
32872
- throw new Error(`Could not find a handler file. Please ensure that the list of \`files\` defined for the returned \`Lambda\` contains a file with the name ${handlerFileName} (+ any extension).`);
32797
+ let handlerFileBase = output.handler;
32798
+ let handlerFile = lambdaFiles[handlerFileBase];
32799
+ const { handler } = output;
32800
+ const handlerMethod = handler.split('.').pop();
32801
+ const handlerFileName = handler.replace(`.${handlerMethod}`, '');
32802
+ // For compiled languages, the launcher file for the Lambda generated
32803
+ // by the Legacy Runtime matches the `handler` defined for it, but for
32804
+ // interpreted languages, the `handler` consists of the launcher file name
32805
+ // without an extension, plus the name of the method inside of that file
32806
+ // that should be invoked, so we have to construct the file path explicitly.
32807
+ if (!handlerFile) {
32808
+ handlerFileBase = handlerFileName + ext;
32809
+ handlerFile = lambdaFiles[handlerFileBase];
32810
+ }
32811
+ if (!handlerFile || !handlerFile.fsPath) {
32812
+ 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\`.`);
32873
32813
  }
32874
- const entry = path_1.join(workPath, '.output', 'server', 'pages', entrypoint);
32814
+ const handlerExtName = path_1.extname(handlerFile.fsPath);
32815
+ const entryBase = path_1.basename(entrypoint).replace(ext, handlerExtName);
32816
+ const entryPath = path_1.join(path_1.dirname(entrypoint), entryBase);
32817
+ const entry = path_1.join(entryRoot, entryPath);
32875
32818
  // We never want to link here, only copy, because the launcher
32876
32819
  // file often has the same name for every entrypoint, which means that
32877
32820
  // every build for every entrypoint overwrites the launcher of the previous
32878
32821
  // one, so linking would end with a broken reference.
32879
32822
  await fs_extra_1.default.ensureDir(path_1.dirname(entry));
32880
- await fs_extra_1.default.copy(handlerFileOrigin, entry);
32823
+ await fs_extra_1.default.copy(handlerFile.fsPath, entry);
32881
32824
  const newFilesEntrypoint = [];
32882
32825
  const newDirectoriesEntrypoint = [];
32883
32826
  const preBuildFiles = Object.values(sourceFilesPreBuild).map(file => {
@@ -32928,7 +32871,7 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32928
32871
  const linkers = Object.entries(lambdaFiles).map(async ([relPath, file]) => {
32929
32872
  const newPath = path_1.join(traceDir, relPath);
32930
32873
  // The handler was already moved into position above.
32931
- if (relPath === handlerFilePath) {
32874
+ if (relPath === handlerFileBase) {
32932
32875
  return;
32933
32876
  }
32934
32877
  tracedFiles.push({ absolutePath: newPath, relativePath: relPath });
@@ -32965,12 +32908,14 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32965
32908
  }
32966
32909
  });
32967
32910
  linkersRuntime = linkersRuntime.concat(linkers);
32968
- const nft = path_1.join(workPath, '.output', 'server', 'pages', `${entrypoint}.nft.json`);
32911
+ const nft = `${entry}.nft.json`;
32969
32912
  const json = JSON.stringify({
32970
32913
  version: 1,
32971
32914
  files: tracedFiles.map(file => ({
32972
32915
  input: normalize_path_1.normalizePath(path_1.relative(path_1.dirname(nft), file.absolutePath)),
32973
- output: normalize_path_1.normalizePath(file.relativePath),
32916
+ // We'd like to place all the dependency files right next
32917
+ // to the final launcher file inside of the Lambda.
32918
+ output: normalize_path_1.normalizePath(path_1.join(entryDir, 'api', file.relativePath)),
32974
32919
  })),
32975
32920
  });
32976
32921
  await fs_extra_1.default.ensureDir(path_1.dirname(nft));
@@ -32983,11 +32928,14 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
32983
32928
  ...newFilesEntrypoint,
32984
32929
  ...newDirectoriesEntrypoint,
32985
32930
  ]);
32986
- const apiRouteHandler = `${path_1.parse(entry).name}.${handlerMethod}`;
32987
32931
  // Add an entry that will later on be added to the `functions-manifest.json`
32988
32932
  // file that is placed inside of the `.output` directory.
32989
- pages[entrypoint] = {
32990
- handler: apiRouteHandler,
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),
32991
32939
  runtime: output.runtime,
32992
32940
  memory: output.memory,
32993
32941
  maxDuration: output.maxDuration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.12.3-canary.34",
3
+ "version": "2.12.3-canary.38",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -30,7 +30,7 @@
30
30
  "@types/node-fetch": "^2.1.6",
31
31
  "@types/semver": "6.0.0",
32
32
  "@types/yazl": "^2.4.1",
33
- "@vercel/frameworks": "0.5.1-canary.16",
33
+ "@vercel/frameworks": "0.5.1-canary.17",
34
34
  "@vercel/ncc": "0.24.0",
35
35
  "aggregate-error": "3.0.1",
36
36
  "async-retry": "1.2.3",
@@ -49,5 +49,5 @@
49
49
  "typescript": "4.3.4",
50
50
  "yazl": "2.4.3"
51
51
  },
52
- "gitHead": "34f4222ca2d3cc5134469daa355a7f67c2054c9b"
52
+ "gitHead": "6792edf32a1a81f240cc1b5c9f9cc756a9a2b83b"
53
53
  }