@vercel/build-utils 2.12.3-canary.28 → 2.12.3-canary.29
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 +26 -10
- package/dist/index.js +26 -10
- package/package.json +2 -2
@@ -10,6 +10,20 @@ const glob_1 = __importDefault(require("./fs/glob"));
|
|
10
10
|
const normalize_path_1 = require("./fs/normalize-path");
|
11
11
|
const lambda_1 = require("./lambda");
|
12
12
|
const _1 = require(".");
|
13
|
+
// `.output` was already created by the Build Command, so we have
|
14
|
+
// to ensure its contents don't get bundled into the Lambda. Similarily,
|
15
|
+
// we don't want to bundle anything from `.vercel` either. Lastly,
|
16
|
+
// Builders/Runtimes didn't have `vercel.json` or `now.json`.
|
17
|
+
const ignoredPaths = ['.output', '.vercel', 'vercel.json', 'now.json'];
|
18
|
+
const shouldIgnorePath = (file, ignoreFilter, ignoreFile) => {
|
19
|
+
const isNative = ignoredPaths.some(item => {
|
20
|
+
return file.startsWith(item);
|
21
|
+
});
|
22
|
+
if (!ignoreFile) {
|
23
|
+
return isNative;
|
24
|
+
}
|
25
|
+
return isNative || ignoreFilter(file);
|
26
|
+
};
|
13
27
|
/**
|
14
28
|
* Convert legacy Runtime to a Plugin.
|
15
29
|
* @param buildRuntime - a legacy build() function from a Runtime
|
@@ -21,22 +35,15 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
21
35
|
return async function build({ workPath }) {
|
22
36
|
const opts = { cwd: workPath };
|
23
37
|
const files = await glob_1.default('**', opts);
|
24
|
-
// `.output` was already created by the Build Command, so we have
|
25
|
-
// to ensure its contents don't get bundled into the Lambda. Similarily,
|
26
|
-
// we don't want to bundle anything from `.vercel` either. Lastly,
|
27
|
-
// Builders/Runtimes didn't have `vercel.json` or `now.json`.
|
28
|
-
const ignoredPaths = ['.output', '.vercel', 'vercel.json', 'now.json'];
|
29
38
|
// We also don't want to provide any files to Runtimes that were ignored
|
30
39
|
// through `.vercelignore` or `.nowignore`, because the Build Step does the same.
|
31
40
|
const ignoreFilter = await _1.getIgnoreFilter(workPath);
|
32
41
|
// We're not passing this as an `ignore` filter to the `glob` function above,
|
33
42
|
// so that we can re-use exactly the same `getIgnoreFilter` method that the
|
34
|
-
// Build Step uses (literally the same code).
|
43
|
+
// Build Step uses (literally the same code). Note that this exclusion only applies
|
44
|
+
// when deploying. Locally, another exclusion further below is needed.
|
35
45
|
for (const file in files) {
|
36
|
-
|
37
|
-
return file.startsWith(item);
|
38
|
-
});
|
39
|
-
if (isNative || ignoreFilter(file)) {
|
46
|
+
if (shouldIgnorePath(file, ignoreFilter, true)) {
|
40
47
|
delete files[file];
|
41
48
|
}
|
42
49
|
}
|
@@ -73,6 +80,15 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
73
80
|
};
|
74
81
|
// @ts-ignore This symbol is a private API
|
75
82
|
const lambdaFiles = output[lambda_1.FILES_SYMBOL];
|
83
|
+
// When deploying, the `files` that are passed to the Legacy Runtimes already
|
84
|
+
// have certain files that are ignored stripped, but locally, that list of
|
85
|
+
// files isn't used by the Legacy Runtimes, so we need to apply the filters
|
86
|
+
// to the outputs that they are returning instead.
|
87
|
+
for (const file in lambdaFiles) {
|
88
|
+
if (shouldIgnorePath(file, ignoreFilter, false)) {
|
89
|
+
delete files[file];
|
90
|
+
}
|
91
|
+
}
|
76
92
|
const entry = path_1.join(workPath, '.output', 'server', 'pages', entrypoint);
|
77
93
|
await fs_extra_1.default.ensureDir(path_1.dirname(entry));
|
78
94
|
await linkOrCopy(files[entrypoint].fsPath, entry);
|
package/dist/index.js
CHANGED
@@ -32757,6 +32757,20 @@ const glob_1 = __importDefault(__webpack_require__(4240));
|
|
32757
32757
|
const normalize_path_1 = __webpack_require__(6261);
|
32758
32758
|
const lambda_1 = __webpack_require__(6721);
|
32759
32759
|
const _1 = __webpack_require__(2855);
|
32760
|
+
// `.output` was already created by the Build Command, so we have
|
32761
|
+
// to ensure its contents don't get bundled into the Lambda. Similarily,
|
32762
|
+
// we don't want to bundle anything from `.vercel` either. Lastly,
|
32763
|
+
// Builders/Runtimes didn't have `vercel.json` or `now.json`.
|
32764
|
+
const ignoredPaths = ['.output', '.vercel', 'vercel.json', 'now.json'];
|
32765
|
+
const shouldIgnorePath = (file, ignoreFilter, ignoreFile) => {
|
32766
|
+
const isNative = ignoredPaths.some(item => {
|
32767
|
+
return file.startsWith(item);
|
32768
|
+
});
|
32769
|
+
if (!ignoreFile) {
|
32770
|
+
return isNative;
|
32771
|
+
}
|
32772
|
+
return isNative || ignoreFilter(file);
|
32773
|
+
};
|
32760
32774
|
/**
|
32761
32775
|
* Convert legacy Runtime to a Plugin.
|
32762
32776
|
* @param buildRuntime - a legacy build() function from a Runtime
|
@@ -32768,22 +32782,15 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32768
32782
|
return async function build({ workPath }) {
|
32769
32783
|
const opts = { cwd: workPath };
|
32770
32784
|
const files = await glob_1.default('**', opts);
|
32771
|
-
// `.output` was already created by the Build Command, so we have
|
32772
|
-
// to ensure its contents don't get bundled into the Lambda. Similarily,
|
32773
|
-
// we don't want to bundle anything from `.vercel` either. Lastly,
|
32774
|
-
// Builders/Runtimes didn't have `vercel.json` or `now.json`.
|
32775
|
-
const ignoredPaths = ['.output', '.vercel', 'vercel.json', 'now.json'];
|
32776
32785
|
// We also don't want to provide any files to Runtimes that were ignored
|
32777
32786
|
// through `.vercelignore` or `.nowignore`, because the Build Step does the same.
|
32778
32787
|
const ignoreFilter = await _1.getIgnoreFilter(workPath);
|
32779
32788
|
// We're not passing this as an `ignore` filter to the `glob` function above,
|
32780
32789
|
// so that we can re-use exactly the same `getIgnoreFilter` method that the
|
32781
|
-
// Build Step uses (literally the same code).
|
32790
|
+
// Build Step uses (literally the same code). Note that this exclusion only applies
|
32791
|
+
// when deploying. Locally, another exclusion further below is needed.
|
32782
32792
|
for (const file in files) {
|
32783
|
-
|
32784
|
-
return file.startsWith(item);
|
32785
|
-
});
|
32786
|
-
if (isNative || ignoreFilter(file)) {
|
32793
|
+
if (shouldIgnorePath(file, ignoreFilter, true)) {
|
32787
32794
|
delete files[file];
|
32788
32795
|
}
|
32789
32796
|
}
|
@@ -32820,6 +32827,15 @@ function convertRuntimeToPlugin(buildRuntime, packageName, ext) {
|
|
32820
32827
|
};
|
32821
32828
|
// @ts-ignore This symbol is a private API
|
32822
32829
|
const lambdaFiles = output[lambda_1.FILES_SYMBOL];
|
32830
|
+
// When deploying, the `files` that are passed to the Legacy Runtimes already
|
32831
|
+
// have certain files that are ignored stripped, but locally, that list of
|
32832
|
+
// files isn't used by the Legacy Runtimes, so we need to apply the filters
|
32833
|
+
// to the outputs that they are returning instead.
|
32834
|
+
for (const file in lambdaFiles) {
|
32835
|
+
if (shouldIgnorePath(file, ignoreFilter, false)) {
|
32836
|
+
delete files[file];
|
32837
|
+
}
|
32838
|
+
}
|
32823
32839
|
const entry = path_1.join(workPath, '.output', 'server', 'pages', entrypoint);
|
32824
32840
|
await fs_extra_1.default.ensureDir(path_1.dirname(entry));
|
32825
32841
|
await linkOrCopy(files[entrypoint].fsPath, entry);
|
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.29",
|
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": "9b3aa41f2e8d40b560969305af8cf26dcd6da8c9"
|
53
53
|
}
|