@vercel/build-utils 2.12.3-canary.40 → 2.12.3-canary.41
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 +11 -80
- package/dist/index.js +11 -80
- package/package.json +2 -2
@@ -78,7 +78,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
78
78
|
// need to be able to easily inspect the output.
|
79
79
|
`api-routes-${pluginName}`);
|
80
80
|
await fs_extra_1.default.ensureDir(traceDir);
|
81
|
-
let newPathsRuntime = new Set();
|
82
81
|
const entryRoot = path_1.join(outputPath, 'server', 'pages');
|
83
82
|
for (const entrypoint of Object.keys(entrypoints)) {
|
84
83
|
const { output } = await buildRuntime({
|
@@ -93,13 +92,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
93
92
|
skipDownload: true,
|
94
93
|
},
|
95
94
|
});
|
96
|
-
// Legacy Runtimes tend to pollute the `workPath` with compiled results,
|
97
|
-
// because the `workPath` used to be a place that was a place where they could
|
98
|
-
// just put anything, but nowadays it's the working directory of the `vercel build`
|
99
|
-
// command, which is the place where the developer keeps their source files,
|
100
|
-
// so we don't want to pollute this space unnecessarily. That means we have to clean
|
101
|
-
// up files that were created by the build, which is done further below.
|
102
|
-
const sourceFilesAfterBuild = await getSourceFiles(workPath, ignoreFilter);
|
103
95
|
// @ts-ignore This symbol is a private API
|
104
96
|
const lambdaFiles = output[lambda_1.FILES_SYMBOL];
|
105
97
|
// When deploying, the `files` that are passed to the Legacy Runtimes already
|
@@ -134,12 +126,9 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
134
126
|
const entryBase = path_1.basename(entrypoint).replace(ext, handlerExtName);
|
135
127
|
const entryPath = path_1.join(path_1.dirname(entrypoint), entryBase);
|
136
128
|
const entry = path_1.join(entryRoot, entryPath);
|
137
|
-
//
|
138
|
-
//
|
139
|
-
// every build for every entrypoint overwrites the launcher of the previous
|
140
|
-
// one, so linking would end with a broken reference.
|
129
|
+
// Create the parent directory of the API Route that will be created
|
130
|
+
// for the current entrypoint inside of `.output/server/pages/api`.
|
141
131
|
await fs_extra_1.default.ensureDir(path_1.dirname(entry));
|
142
|
-
await fs_extra_1.default.copy(handlerFile.fsPath, entry);
|
143
132
|
// For compiled languages, the launcher file will be binary and therefore
|
144
133
|
// won't try to import a user-provided request handler (instead, it will
|
145
134
|
// contain it). But for interpreted languages, the launcher might try to
|
@@ -187,52 +176,15 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
187
176
|
else {
|
188
177
|
await fs_extra_1.default.copy(handlerFile.fsPath, entry);
|
189
178
|
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
//
|
196
|
-
//
|
197
|
-
|
198
|
-
|
199
|
-
// directories, and listing directories separately also speeds up the
|
200
|
-
// build because we can just delete them, which wipes all of their nested
|
201
|
-
// paths, instead of iterating through all files that should be deleted.
|
202
|
-
for (const file in sourceFilesAfterBuild) {
|
203
|
-
if (!sourceFilesPreBuild[file]) {
|
204
|
-
const path = sourceFilesAfterBuild[file].fsPath;
|
205
|
-
const dirPath = path_1.dirname(path);
|
206
|
-
// If none of the files that were present before the entrypoint
|
207
|
-
// was processed are contained within the directory we're looking
|
208
|
-
// at right now, then we know it's a newly added directory
|
209
|
-
// and it can therefore be removed later on.
|
210
|
-
const isNewDir = !preBuildFiles.some(filePath => {
|
211
|
-
return path_1.dirname(filePath).startsWith(dirPath);
|
212
|
-
});
|
213
|
-
// Check out the list of tracked directories that were
|
214
|
-
// newly added and see if one of them contains the path
|
215
|
-
// we're looking at.
|
216
|
-
const hasParentDir = newDirectoriesEntrypoint.some(dir => {
|
217
|
-
return path.startsWith(dir);
|
218
|
-
});
|
219
|
-
// If we have already tracked a directory that was newly
|
220
|
-
// added that sits above the file or directory that we're
|
221
|
-
// looking at, we don't need to add more entries to the list
|
222
|
-
// because when the parent will get removed in the future,
|
223
|
-
// all of its children (and therefore the path we're looking at)
|
224
|
-
// will automatically get removed anyways.
|
225
|
-
if (hasParentDir) {
|
226
|
-
continue;
|
227
|
-
}
|
228
|
-
if (isNewDir) {
|
229
|
-
newDirectoriesEntrypoint.push(dirPath);
|
230
|
-
}
|
231
|
-
else {
|
232
|
-
newFilesEntrypoint.push(path);
|
233
|
-
}
|
234
|
-
}
|
235
|
-
}
|
179
|
+
// Legacy Runtimes based on interpreted languages will create a new launcher file
|
180
|
+
// for every entrypoint, but they will create each one inside `workPath`, which means that
|
181
|
+
// the launcher for one entrypoint will overwrite the launcher provided for the previous
|
182
|
+
// entrypoint. That's why, above, we copy the file contents into the new destination (and
|
183
|
+
// optionally transform them along the way), instead of linking. We then also want to remove
|
184
|
+
// the copy origin right here, so that the `workPath` doesn't contain a useless launcher file
|
185
|
+
// once the build has finished running.
|
186
|
+
await fs_extra_1.default.remove(handlerFile.fsPath);
|
187
|
+
_1.debug(`Removed temporary file "${handlerFile.fsPath}"`);
|
236
188
|
const nft = `${entry}.nft.json`;
|
237
189
|
const json = JSON.stringify({
|
238
190
|
version: 2,
|
@@ -250,16 +202,7 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
250
202
|
})
|
251
203
|
.filter(Boolean),
|
252
204
|
});
|
253
|
-
await fs_extra_1.default.ensureDir(path_1.dirname(nft));
|
254
205
|
await fs_extra_1.default.writeFile(nft, json);
|
255
|
-
// Extend the list of directories and files that were created by the
|
256
|
-
// Legacy Runtime with the list of directories and files that were
|
257
|
-
// created for the entrypoint that was just processed above.
|
258
|
-
newPathsRuntime = new Set([
|
259
|
-
...newPathsRuntime,
|
260
|
-
...newFilesEntrypoint,
|
261
|
-
...newDirectoriesEntrypoint,
|
262
|
-
]);
|
263
206
|
// Add an entry that will later on be added to the `functions-manifest.json`
|
264
207
|
// file that is placed inside of the `.output` directory.
|
265
208
|
pages[normalize_path_1.normalizePath(entryPath)] = {
|
@@ -275,18 +218,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
275
218
|
allowQuery: output.allowQuery,
|
276
219
|
};
|
277
220
|
}
|
278
|
-
// A list of all the files that were created by the Legacy Runtime,
|
279
|
-
// which we'd like to remove from the File System.
|
280
|
-
const toRemove = Array.from(newPathsRuntime).map(path => {
|
281
|
-
_1.debug(`Removing ${path} as part of cleanup`);
|
282
|
-
return fs_extra_1.default.remove(path);
|
283
|
-
});
|
284
|
-
// Once all the entrypoints have been processed, we'd like to
|
285
|
-
// remove all the files from `workPath` that originally weren't present
|
286
|
-
// before the Legacy Runtime began running, because the `workPath`
|
287
|
-
// is nowadays the directory in which the user keeps their source code, since
|
288
|
-
// we're no longer running separate parallel builds for every Legacy Runtime.
|
289
|
-
await Promise.all(toRemove);
|
290
221
|
// Add any Serverless Functions that were exposed by the Legacy Runtime
|
291
222
|
// to the `functions-manifest.json` file provided in `.output`.
|
292
223
|
await updateFunctionsManifest({ workPath, pages });
|
package/dist/index.js
CHANGED
@@ -32760,7 +32760,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32760
32760
|
// need to be able to easily inspect the output.
|
32761
32761
|
`api-routes-${pluginName}`);
|
32762
32762
|
await fs_extra_1.default.ensureDir(traceDir);
|
32763
|
-
let newPathsRuntime = new Set();
|
32764
32763
|
const entryRoot = path_1.join(outputPath, 'server', 'pages');
|
32765
32764
|
for (const entrypoint of Object.keys(entrypoints)) {
|
32766
32765
|
const { output } = await buildRuntime({
|
@@ -32775,13 +32774,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32775
32774
|
skipDownload: true,
|
32776
32775
|
},
|
32777
32776
|
});
|
32778
|
-
// Legacy Runtimes tend to pollute the `workPath` with compiled results,
|
32779
|
-
// because the `workPath` used to be a place that was a place where they could
|
32780
|
-
// just put anything, but nowadays it's the working directory of the `vercel build`
|
32781
|
-
// command, which is the place where the developer keeps their source files,
|
32782
|
-
// so we don't want to pollute this space unnecessarily. That means we have to clean
|
32783
|
-
// up files that were created by the build, which is done further below.
|
32784
|
-
const sourceFilesAfterBuild = await getSourceFiles(workPath, ignoreFilter);
|
32785
32777
|
// @ts-ignore This symbol is a private API
|
32786
32778
|
const lambdaFiles = output[lambda_1.FILES_SYMBOL];
|
32787
32779
|
// When deploying, the `files` that are passed to the Legacy Runtimes already
|
@@ -32816,12 +32808,9 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32816
32808
|
const entryBase = path_1.basename(entrypoint).replace(ext, handlerExtName);
|
32817
32809
|
const entryPath = path_1.join(path_1.dirname(entrypoint), entryBase);
|
32818
32810
|
const entry = path_1.join(entryRoot, entryPath);
|
32819
|
-
//
|
32820
|
-
//
|
32821
|
-
// every build for every entrypoint overwrites the launcher of the previous
|
32822
|
-
// one, so linking would end with a broken reference.
|
32811
|
+
// Create the parent directory of the API Route that will be created
|
32812
|
+
// for the current entrypoint inside of `.output/server/pages/api`.
|
32823
32813
|
await fs_extra_1.default.ensureDir(path_1.dirname(entry));
|
32824
|
-
await fs_extra_1.default.copy(handlerFile.fsPath, entry);
|
32825
32814
|
// For compiled languages, the launcher file will be binary and therefore
|
32826
32815
|
// won't try to import a user-provided request handler (instead, it will
|
32827
32816
|
// contain it). But for interpreted languages, the launcher might try to
|
@@ -32869,52 +32858,15 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32869
32858
|
else {
|
32870
32859
|
await fs_extra_1.default.copy(handlerFile.fsPath, entry);
|
32871
32860
|
}
|
32872
|
-
|
32873
|
-
|
32874
|
-
|
32875
|
-
|
32876
|
-
|
32877
|
-
//
|
32878
|
-
//
|
32879
|
-
|
32880
|
-
|
32881
|
-
// directories, and listing directories separately also speeds up the
|
32882
|
-
// build because we can just delete them, which wipes all of their nested
|
32883
|
-
// paths, instead of iterating through all files that should be deleted.
|
32884
|
-
for (const file in sourceFilesAfterBuild) {
|
32885
|
-
if (!sourceFilesPreBuild[file]) {
|
32886
|
-
const path = sourceFilesAfterBuild[file].fsPath;
|
32887
|
-
const dirPath = path_1.dirname(path);
|
32888
|
-
// If none of the files that were present before the entrypoint
|
32889
|
-
// was processed are contained within the directory we're looking
|
32890
|
-
// at right now, then we know it's a newly added directory
|
32891
|
-
// and it can therefore be removed later on.
|
32892
|
-
const isNewDir = !preBuildFiles.some(filePath => {
|
32893
|
-
return path_1.dirname(filePath).startsWith(dirPath);
|
32894
|
-
});
|
32895
|
-
// Check out the list of tracked directories that were
|
32896
|
-
// newly added and see if one of them contains the path
|
32897
|
-
// we're looking at.
|
32898
|
-
const hasParentDir = newDirectoriesEntrypoint.some(dir => {
|
32899
|
-
return path.startsWith(dir);
|
32900
|
-
});
|
32901
|
-
// If we have already tracked a directory that was newly
|
32902
|
-
// added that sits above the file or directory that we're
|
32903
|
-
// looking at, we don't need to add more entries to the list
|
32904
|
-
// because when the parent will get removed in the future,
|
32905
|
-
// all of its children (and therefore the path we're looking at)
|
32906
|
-
// will automatically get removed anyways.
|
32907
|
-
if (hasParentDir) {
|
32908
|
-
continue;
|
32909
|
-
}
|
32910
|
-
if (isNewDir) {
|
32911
|
-
newDirectoriesEntrypoint.push(dirPath);
|
32912
|
-
}
|
32913
|
-
else {
|
32914
|
-
newFilesEntrypoint.push(path);
|
32915
|
-
}
|
32916
|
-
}
|
32917
|
-
}
|
32861
|
+
// Legacy Runtimes based on interpreted languages will create a new launcher file
|
32862
|
+
// for every entrypoint, but they will create each one inside `workPath`, which means that
|
32863
|
+
// the launcher for one entrypoint will overwrite the launcher provided for the previous
|
32864
|
+
// entrypoint. That's why, above, we copy the file contents into the new destination (and
|
32865
|
+
// optionally transform them along the way), instead of linking. We then also want to remove
|
32866
|
+
// the copy origin right here, so that the `workPath` doesn't contain a useless launcher file
|
32867
|
+
// once the build has finished running.
|
32868
|
+
await fs_extra_1.default.remove(handlerFile.fsPath);
|
32869
|
+
_1.debug(`Removed temporary file "${handlerFile.fsPath}"`);
|
32918
32870
|
const nft = `${entry}.nft.json`;
|
32919
32871
|
const json = JSON.stringify({
|
32920
32872
|
version: 2,
|
@@ -32932,16 +32884,7 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32932
32884
|
})
|
32933
32885
|
.filter(Boolean),
|
32934
32886
|
});
|
32935
|
-
await fs_extra_1.default.ensureDir(path_1.dirname(nft));
|
32936
32887
|
await fs_extra_1.default.writeFile(nft, json);
|
32937
|
-
// Extend the list of directories and files that were created by the
|
32938
|
-
// Legacy Runtime with the list of directories and files that were
|
32939
|
-
// created for the entrypoint that was just processed above.
|
32940
|
-
newPathsRuntime = new Set([
|
32941
|
-
...newPathsRuntime,
|
32942
|
-
...newFilesEntrypoint,
|
32943
|
-
...newDirectoriesEntrypoint,
|
32944
|
-
]);
|
32945
32888
|
// Add an entry that will later on be added to the `functions-manifest.json`
|
32946
32889
|
// file that is placed inside of the `.output` directory.
|
32947
32890
|
pages[normalize_path_1.normalizePath(entryPath)] = {
|
@@ -32957,18 +32900,6 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32957
32900
|
allowQuery: output.allowQuery,
|
32958
32901
|
};
|
32959
32902
|
}
|
32960
|
-
// A list of all the files that were created by the Legacy Runtime,
|
32961
|
-
// which we'd like to remove from the File System.
|
32962
|
-
const toRemove = Array.from(newPathsRuntime).map(path => {
|
32963
|
-
_1.debug(`Removing ${path} as part of cleanup`);
|
32964
|
-
return fs_extra_1.default.remove(path);
|
32965
|
-
});
|
32966
|
-
// Once all the entrypoints have been processed, we'd like to
|
32967
|
-
// remove all the files from `workPath` that originally weren't present
|
32968
|
-
// before the Legacy Runtime began running, because the `workPath`
|
32969
|
-
// is nowadays the directory in which the user keeps their source code, since
|
32970
|
-
// we're no longer running separate parallel builds for every Legacy Runtime.
|
32971
|
-
await Promise.all(toRemove);
|
32972
32903
|
// Add any Serverless Functions that were exposed by the Legacy Runtime
|
32973
32904
|
// to the `functions-manifest.json` file provided in `.output`.
|
32974
32905
|
await updateFunctionsManifest({ workPath, 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.41",
|
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": "35c8fc272905524eeb83268bdc09edb165d3382a"
|
53
53
|
}
|