@vercel/build-utils 2.12.3-canary.38 → 2.12.3-canary.39
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.
- package/dist/convert-runtime-to-plugin.js +15 -65
- package/dist/index.js +15 -65
- package/package.json +2 -2
@@ -78,7 +78,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
78
78
|
`api-routes-${pluginName}`);
|
79
79
|
await fs_extra_1.default.ensureDir(traceDir);
|
80
80
|
let newPathsRuntime = new Set();
|
81
|
-
let linkersRuntime = [];
|
82
81
|
const entryDir = path_1.join('.output', 'server', 'pages');
|
83
82
|
const entryRoot = path_1.join(workPath, entryDir);
|
84
83
|
for (const entrypoint of Object.keys(entrypoints)) {
|
@@ -185,56 +184,22 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
185
184
|
}
|
186
185
|
}
|
187
186
|
}
|
188
|
-
const tracedFiles = [];
|
189
|
-
const linkers = Object.entries(lambdaFiles).map(async ([relPath, file]) => {
|
190
|
-
const newPath = path_1.join(traceDir, relPath);
|
191
|
-
// The handler was already moved into position above.
|
192
|
-
if (relPath === handlerFileBase) {
|
193
|
-
return;
|
194
|
-
}
|
195
|
-
tracedFiles.push({ absolutePath: newPath, relativePath: relPath });
|
196
|
-
const { fsPath, type } = file;
|
197
|
-
if (fsPath) {
|
198
|
-
await fs_extra_1.default.ensureDir(path_1.dirname(newPath));
|
199
|
-
const isNewFile = newFilesEntrypoint.includes(fsPath);
|
200
|
-
const isInsideNewDirectory = newDirectoriesEntrypoint.some(dirPath => {
|
201
|
-
return fsPath.startsWith(dirPath);
|
202
|
-
});
|
203
|
-
// With this, we're making sure that files in the `workPath` that existed
|
204
|
-
// before the Legacy Runtime was invoked (source files) are linked from
|
205
|
-
// `.output` instead of copying there (the latter only happens if linking fails),
|
206
|
-
// which is the fastest solution. However, files that are created fresh
|
207
|
-
// by the Legacy Runtimes are always copied, because their link destinations
|
208
|
-
// are likely to be overwritten every time an entrypoint is processed by
|
209
|
-
// the Legacy Runtime. This is likely to overwrite the destination on subsequent
|
210
|
-
// runs, but that's also how `workPath` used to work originally, without
|
211
|
-
// the File System API (meaning that there was one `workPath` for all entrypoints).
|
212
|
-
if (isNewFile || isInsideNewDirectory) {
|
213
|
-
_1.debug(`Copying from ${fsPath} to ${newPath}`);
|
214
|
-
await fs_extra_1.default.copy(fsPath, newPath);
|
215
|
-
}
|
216
|
-
else {
|
217
|
-
await linkOrCopy(fsPath, newPath);
|
218
|
-
}
|
219
|
-
}
|
220
|
-
else if (type === 'FileBlob') {
|
221
|
-
const { data, mode } = file;
|
222
|
-
await fs_extra_1.default.writeFile(newPath, data, { mode });
|
223
|
-
}
|
224
|
-
else {
|
225
|
-
throw new Error(`Unknown file type: ${type}`);
|
226
|
-
}
|
227
|
-
});
|
228
|
-
linkersRuntime = linkersRuntime.concat(linkers);
|
229
187
|
const nft = `${entry}.nft.json`;
|
230
188
|
const json = JSON.stringify({
|
231
|
-
version:
|
232
|
-
files:
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
189
|
+
version: 2,
|
190
|
+
files: Object.keys(lambdaFiles)
|
191
|
+
.map(file => {
|
192
|
+
const { fsPath } = lambdaFiles[file];
|
193
|
+
if (!fsPath) {
|
194
|
+
throw new Error(`File "${file}" is missing valid \`fsPath\` property`);
|
195
|
+
}
|
196
|
+
// The handler was already moved into position above.
|
197
|
+
if (file === handlerFileBase) {
|
198
|
+
return;
|
199
|
+
}
|
200
|
+
return normalize_path_1.normalizePath(path_1.relative(path_1.dirname(nft), fsPath));
|
201
|
+
})
|
202
|
+
.filter(Boolean),
|
238
203
|
});
|
239
204
|
await fs_extra_1.default.ensureDir(path_1.dirname(nft));
|
240
205
|
await fs_extra_1.default.writeFile(nft, json);
|
@@ -261,11 +226,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
261
226
|
allowQuery: output.allowQuery,
|
262
227
|
};
|
263
228
|
}
|
264
|
-
// Instead of of waiting for all of the linking to be done for every
|
265
|
-
// entrypoint before processing the next one, we immediately handle all
|
266
|
-
// of them one after the other, while then waiting for the linking
|
267
|
-
// to finish right here, before we clean up newly created files below.
|
268
|
-
await Promise.all(linkersRuntime);
|
269
229
|
// A list of all the files that were created by the Legacy Runtime,
|
270
230
|
// which we'd like to remove from the File System.
|
271
231
|
const toRemove = Array.from(newPathsRuntime).map(path => {
|
@@ -284,16 +244,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
284
244
|
};
|
285
245
|
}
|
286
246
|
exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
|
287
|
-
async function linkOrCopy(existingPath, newPath) {
|
288
|
-
try {
|
289
|
-
await fs_extra_1.default.createLink(existingPath, newPath);
|
290
|
-
}
|
291
|
-
catch (err) {
|
292
|
-
if (err.code !== 'EEXIST') {
|
293
|
-
await fs_extra_1.default.copyFile(existingPath, newPath);
|
294
|
-
}
|
295
|
-
}
|
296
|
-
}
|
297
247
|
async function readJson(filePath) {
|
298
248
|
try {
|
299
249
|
const str = await fs_extra_1.default.readFile(filePath, 'utf8');
|
@@ -314,7 +264,7 @@ async function updateFunctionsManifest({ workPath, pages, }) {
|
|
314
264
|
const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
|
315
265
|
const functionsManifest = await readJson(functionsManifestPath);
|
316
266
|
if (!functionsManifest.version)
|
317
|
-
functionsManifest.version =
|
267
|
+
functionsManifest.version = 2;
|
318
268
|
if (!functionsManifest.pages)
|
319
269
|
functionsManifest.pages = {};
|
320
270
|
for (const [pageKey, pageConfig] of Object.entries(pages)) {
|
package/dist/index.js
CHANGED
@@ -32760,7 +32760,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32760
32760
|
`api-routes-${pluginName}`);
|
32761
32761
|
await fs_extra_1.default.ensureDir(traceDir);
|
32762
32762
|
let newPathsRuntime = new Set();
|
32763
|
-
let linkersRuntime = [];
|
32764
32763
|
const entryDir = path_1.join('.output', 'server', 'pages');
|
32765
32764
|
const entryRoot = path_1.join(workPath, entryDir);
|
32766
32765
|
for (const entrypoint of Object.keys(entrypoints)) {
|
@@ -32867,56 +32866,22 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32867
32866
|
}
|
32868
32867
|
}
|
32869
32868
|
}
|
32870
|
-
const tracedFiles = [];
|
32871
|
-
const linkers = Object.entries(lambdaFiles).map(async ([relPath, file]) => {
|
32872
|
-
const newPath = path_1.join(traceDir, relPath);
|
32873
|
-
// The handler was already moved into position above.
|
32874
|
-
if (relPath === handlerFileBase) {
|
32875
|
-
return;
|
32876
|
-
}
|
32877
|
-
tracedFiles.push({ absolutePath: newPath, relativePath: relPath });
|
32878
|
-
const { fsPath, type } = file;
|
32879
|
-
if (fsPath) {
|
32880
|
-
await fs_extra_1.default.ensureDir(path_1.dirname(newPath));
|
32881
|
-
const isNewFile = newFilesEntrypoint.includes(fsPath);
|
32882
|
-
const isInsideNewDirectory = newDirectoriesEntrypoint.some(dirPath => {
|
32883
|
-
return fsPath.startsWith(dirPath);
|
32884
|
-
});
|
32885
|
-
// With this, we're making sure that files in the `workPath` that existed
|
32886
|
-
// before the Legacy Runtime was invoked (source files) are linked from
|
32887
|
-
// `.output` instead of copying there (the latter only happens if linking fails),
|
32888
|
-
// which is the fastest solution. However, files that are created fresh
|
32889
|
-
// by the Legacy Runtimes are always copied, because their link destinations
|
32890
|
-
// are likely to be overwritten every time an entrypoint is processed by
|
32891
|
-
// the Legacy Runtime. This is likely to overwrite the destination on subsequent
|
32892
|
-
// runs, but that's also how `workPath` used to work originally, without
|
32893
|
-
// the File System API (meaning that there was one `workPath` for all entrypoints).
|
32894
|
-
if (isNewFile || isInsideNewDirectory) {
|
32895
|
-
_1.debug(`Copying from ${fsPath} to ${newPath}`);
|
32896
|
-
await fs_extra_1.default.copy(fsPath, newPath);
|
32897
|
-
}
|
32898
|
-
else {
|
32899
|
-
await linkOrCopy(fsPath, newPath);
|
32900
|
-
}
|
32901
|
-
}
|
32902
|
-
else if (type === 'FileBlob') {
|
32903
|
-
const { data, mode } = file;
|
32904
|
-
await fs_extra_1.default.writeFile(newPath, data, { mode });
|
32905
|
-
}
|
32906
|
-
else {
|
32907
|
-
throw new Error(`Unknown file type: ${type}`);
|
32908
|
-
}
|
32909
|
-
});
|
32910
|
-
linkersRuntime = linkersRuntime.concat(linkers);
|
32911
32869
|
const nft = `${entry}.nft.json`;
|
32912
32870
|
const json = JSON.stringify({
|
32913
|
-
version:
|
32914
|
-
files:
|
32915
|
-
|
32916
|
-
|
32917
|
-
|
32918
|
-
|
32919
|
-
|
32871
|
+
version: 2,
|
32872
|
+
files: Object.keys(lambdaFiles)
|
32873
|
+
.map(file => {
|
32874
|
+
const { fsPath } = lambdaFiles[file];
|
32875
|
+
if (!fsPath) {
|
32876
|
+
throw new Error(`File "${file}" is missing valid \`fsPath\` property`);
|
32877
|
+
}
|
32878
|
+
// The handler was already moved into position above.
|
32879
|
+
if (file === handlerFileBase) {
|
32880
|
+
return;
|
32881
|
+
}
|
32882
|
+
return normalize_path_1.normalizePath(path_1.relative(path_1.dirname(nft), fsPath));
|
32883
|
+
})
|
32884
|
+
.filter(Boolean),
|
32920
32885
|
});
|
32921
32886
|
await fs_extra_1.default.ensureDir(path_1.dirname(nft));
|
32922
32887
|
await fs_extra_1.default.writeFile(nft, json);
|
@@ -32943,11 +32908,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32943
32908
|
allowQuery: output.allowQuery,
|
32944
32909
|
};
|
32945
32910
|
}
|
32946
|
-
// Instead of of waiting for all of the linking to be done for every
|
32947
|
-
// entrypoint before processing the next one, we immediately handle all
|
32948
|
-
// of them one after the other, while then waiting for the linking
|
32949
|
-
// to finish right here, before we clean up newly created files below.
|
32950
|
-
await Promise.all(linkersRuntime);
|
32951
32911
|
// A list of all the files that were created by the Legacy Runtime,
|
32952
32912
|
// which we'd like to remove from the File System.
|
32953
32913
|
const toRemove = Array.from(newPathsRuntime).map(path => {
|
@@ -32966,16 +32926,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32966
32926
|
};
|
32967
32927
|
}
|
32968
32928
|
exports.convertRuntimeToPlugin = convertRuntimeToPlugin;
|
32969
|
-
async function linkOrCopy(existingPath, newPath) {
|
32970
|
-
try {
|
32971
|
-
await fs_extra_1.default.createLink(existingPath, newPath);
|
32972
|
-
}
|
32973
|
-
catch (err) {
|
32974
|
-
if (err.code !== 'EEXIST') {
|
32975
|
-
await fs_extra_1.default.copyFile(existingPath, newPath);
|
32976
|
-
}
|
32977
|
-
}
|
32978
|
-
}
|
32979
32929
|
async function readJson(filePath) {
|
32980
32930
|
try {
|
32981
32931
|
const str = await fs_extra_1.default.readFile(filePath, 'utf8');
|
@@ -32996,7 +32946,7 @@ async function updateFunctionsManifest({ workPath, pages, }) {
|
|
32996
32946
|
const functionsManifestPath = path_1.join(workPath, '.output', 'functions-manifest.json');
|
32997
32947
|
const functionsManifest = await readJson(functionsManifestPath);
|
32998
32948
|
if (!functionsManifest.version)
|
32999
|
-
functionsManifest.version =
|
32949
|
+
functionsManifest.version = 2;
|
33000
32950
|
if (!functionsManifest.pages)
|
33001
32951
|
functionsManifest.pages = {};
|
33002
32952
|
for (const [pageKey, pageConfig] of Object.entries(pages)) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vercel/build-utils",
|
3
|
-
"version": "2.12.3-canary.
|
3
|
+
"version": "2.12.3-canary.39",
|
4
4
|
"license": "MIT",
|
5
5
|
"main": "./dist/index.js",
|
6
6
|
"types": "./dist/index.d.js",
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"typescript": "4.3.4",
|
50
50
|
"yazl": "2.4.3"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "2c86ac654ccde97426127fd0a6ffd04253227c50"
|
53
53
|
}
|