@vercel/static-build 0.25.0 → 0.25.2-canary.0
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/index.js +4010 -7189
- package/dist/utils/build-output-v3.js +2 -19
- package/package.json +10 -9
- package/dist/utils/build-output-v2.js +0 -123
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.readConfig = exports.getBuildOutputDirectory = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const BUILD_OUTPUT_DIR = '.vercel/output';
|
|
7
7
|
/**
|
|
8
|
-
* Returns the path to the Build Output
|
|
8
|
+
* Returns the path to the Build Output v3 directory when the
|
|
9
9
|
* `config.json` file was created by the framework / build script,
|
|
10
10
|
* or `undefined` if the framework did not create the v3 output.
|
|
11
11
|
*/
|
|
@@ -36,20 +36,3 @@ async function readConfig(path) {
|
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
exports.readConfig = readConfig;
|
|
39
|
-
function createBuildOutput(meta, buildCommand, buildOutputPath, framework) {
|
|
40
|
-
if (!meta.cliVersion) {
|
|
41
|
-
let buildCommandName;
|
|
42
|
-
if (buildCommand)
|
|
43
|
-
buildCommandName = `"${buildCommand}"`;
|
|
44
|
-
else if (framework)
|
|
45
|
-
buildCommandName = framework.name;
|
|
46
|
-
else
|
|
47
|
-
buildCommandName = 'the "build" script';
|
|
48
|
-
throw new Error(`Detected Build Output v3 from ${buildCommandName}, but this Deployment is not using \`vercel build\`.\nPlease set the \`ENABLE_VC_BUILD=1\` environment variable.`);
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
buildOutputVersion: 3,
|
|
52
|
-
buildOutputPath,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
exports.createBuildOutput = createBuildOutput;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/static-build",
|
|
3
|
-
"version": "0.25.0",
|
|
3
|
+
"version": "0.25.2-canary.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"homepage": "https://vercel.com/docs/build-step",
|
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "node build",
|
|
17
|
-
"test
|
|
18
|
-
"test-
|
|
17
|
+
"test": "jest --env node --verbose --bail --runInBand",
|
|
18
|
+
"test-unit": "yarn test test/build.test.ts test/prepare-cache.test.ts",
|
|
19
|
+
"test-integration-once": "yarn test test/integration-*.test.js",
|
|
19
20
|
"prepublishOnly": "node build"
|
|
20
21
|
},
|
|
21
22
|
"jest": {
|
|
@@ -31,21 +32,21 @@
|
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@types/aws-lambda": "8.10.64",
|
|
33
34
|
"@types/cross-spawn": "6.0.0",
|
|
34
|
-
"@types/fs-extra": "9.0.13",
|
|
35
35
|
"@types/jest": "27.4.1",
|
|
36
36
|
"@types/ms": "0.7.31",
|
|
37
37
|
"@types/node-fetch": "2.5.4",
|
|
38
38
|
"@types/promise-timeout": "1.3.0",
|
|
39
|
-
"@vercel/build-utils": "3.0.
|
|
40
|
-
"@vercel/frameworks": "0.9.0",
|
|
39
|
+
"@vercel/build-utils": "3.0.2-canary.0",
|
|
40
|
+
"@vercel/frameworks": "0.9.1-canary.0",
|
|
41
41
|
"@vercel/ncc": "0.24.0",
|
|
42
|
-
"@vercel/routing-utils": "1.13.
|
|
42
|
+
"@vercel/routing-utils": "1.13.3-canary.0",
|
|
43
43
|
"fs-extra": "10.0.0",
|
|
44
44
|
"get-port": "5.0.0",
|
|
45
45
|
"is-port-reachable": "2.0.1",
|
|
46
46
|
"ms": "2.1.2",
|
|
47
47
|
"node-fetch": "2.6.1",
|
|
48
|
-
"rc9": "1.2.0"
|
|
48
|
+
"rc9": "1.2.0",
|
|
49
|
+
"typescript": "4.3.4"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "f26858b735ad5d54e01afa67133b9f9456fbe72f"
|
|
51
52
|
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createBuildOutput = exports.readBuildOutputDirectory = exports.getBuildOutputDirectory = void 0;
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const fs_extra_1 = require("fs-extra");
|
|
9
|
-
const build_utils_1 = require("@vercel/build-utils");
|
|
10
|
-
const _shared_1 = require("./_shared");
|
|
11
|
-
const BUILD_OUTPUT_DIR = '.output';
|
|
12
|
-
const BRIDGE_MIDDLEWARE_V2_TO_V3 = `
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// appended to convert v2 middleware to v3 middleware
|
|
16
|
-
export default async (request) => {
|
|
17
|
-
const { response } = await _ENTRIES['middleware_pages/_middleware'].default({ request });
|
|
18
|
-
return response;
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the path to the Build Output API v2 directory when the
|
|
23
|
-
* `config.json` file was created by the framework / build script,
|
|
24
|
-
* or `undefined` if the framework did not create the v3 output.
|
|
25
|
-
*/
|
|
26
|
-
async function getBuildOutputDirectory(workingDir) {
|
|
27
|
-
const outputDir = path_1.default.join(workingDir, BUILD_OUTPUT_DIR);
|
|
28
|
-
const outputPathExists = await fs_extra_1.pathExists(outputDir);
|
|
29
|
-
if (outputPathExists) {
|
|
30
|
-
return outputDir;
|
|
31
|
-
}
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
34
|
-
exports.getBuildOutputDirectory = getBuildOutputDirectory;
|
|
35
|
-
/**
|
|
36
|
-
* Reads the BUILD_OUTPUT_DIR directory and returns and object
|
|
37
|
-
* that should be merged with the build outputs.
|
|
38
|
-
*/
|
|
39
|
-
async function readBuildOutputDirectory({ workPath, }) {
|
|
40
|
-
// Functions are not supported, but are used to support Middleware
|
|
41
|
-
const functions = {};
|
|
42
|
-
// Routes are not supported, but are used to support Middleware
|
|
43
|
-
const routes = [];
|
|
44
|
-
const middleware = await getMiddleware(workPath);
|
|
45
|
-
if (middleware) {
|
|
46
|
-
routes.push(middleware.route);
|
|
47
|
-
functions['middleware'] = new build_utils_1.EdgeFunction({
|
|
48
|
-
deploymentTarget: 'v8-worker',
|
|
49
|
-
entrypoint: '_middleware.js',
|
|
50
|
-
files: {
|
|
51
|
-
'_middleware.js': middleware.file,
|
|
52
|
-
},
|
|
53
|
-
name: 'middleware',
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
const staticFiles = await readStaticFiles({ workPath });
|
|
57
|
-
const outputs = {
|
|
58
|
-
staticFiles: _shared_1.isObjectEmpty(staticFiles) ? null : staticFiles,
|
|
59
|
-
functions: _shared_1.isObjectEmpty(functions) ? null : functions,
|
|
60
|
-
routes: routes.length ? routes : null,
|
|
61
|
-
};
|
|
62
|
-
if (outputs.functions) {
|
|
63
|
-
build_utils_1.debug(`Detected Serverless Functions in "${BUILD_OUTPUT_DIR}"`);
|
|
64
|
-
}
|
|
65
|
-
if (outputs.staticFiles) {
|
|
66
|
-
build_utils_1.debug(`Detected Static Assets in "${BUILD_OUTPUT_DIR}"`);
|
|
67
|
-
}
|
|
68
|
-
if (outputs.routes) {
|
|
69
|
-
build_utils_1.debug(`Detected Routes Configuration in "${BUILD_OUTPUT_DIR}"`);
|
|
70
|
-
}
|
|
71
|
-
return outputs;
|
|
72
|
-
}
|
|
73
|
-
exports.readBuildOutputDirectory = readBuildOutputDirectory;
|
|
74
|
-
async function getMiddleware(workPath) {
|
|
75
|
-
const manifestPath = path_1.default.join(workPath, BUILD_OUTPUT_DIR, 'functions-manifest.json');
|
|
76
|
-
try {
|
|
77
|
-
const manifest = await fs_extra_1.readJson(manifestPath);
|
|
78
|
-
if (manifest.pages['_middleware.js'].runtime !== 'web') {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
if (error.code !== 'ENOENT')
|
|
84
|
-
throw error;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const middlewareRelativePath = path_1.default.join(BUILD_OUTPUT_DIR, 'server/pages/_middleware.js');
|
|
88
|
-
const middlewareAbsoluatePath = path_1.default.join(workPath, middlewareRelativePath);
|
|
89
|
-
await fs_extra_1.appendFile(middlewareAbsoluatePath, BRIDGE_MIDDLEWARE_V2_TO_V3);
|
|
90
|
-
const route = {
|
|
91
|
-
src: '/(.*)',
|
|
92
|
-
middlewarePath: 'middleware',
|
|
93
|
-
continue: true,
|
|
94
|
-
};
|
|
95
|
-
return {
|
|
96
|
-
route,
|
|
97
|
-
file: new build_utils_1.FileFsRef({
|
|
98
|
-
fsPath: middlewareRelativePath,
|
|
99
|
-
}),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
async function readStaticFiles({ workPath, }) {
|
|
103
|
-
const staticFilePath = path_1.default.join(workPath, BUILD_OUTPUT_DIR, 'static');
|
|
104
|
-
const staticFiles = await build_utils_1.glob('**', {
|
|
105
|
-
cwd: staticFilePath,
|
|
106
|
-
});
|
|
107
|
-
return staticFiles;
|
|
108
|
-
}
|
|
109
|
-
async function createBuildOutput(workPath) {
|
|
110
|
-
let output = {};
|
|
111
|
-
const routes = [];
|
|
112
|
-
const extraOutputs = await readBuildOutputDirectory({
|
|
113
|
-
workPath,
|
|
114
|
-
});
|
|
115
|
-
if (extraOutputs.routes) {
|
|
116
|
-
routes.push(...extraOutputs.routes);
|
|
117
|
-
}
|
|
118
|
-
if (extraOutputs.staticFiles) {
|
|
119
|
-
output = Object.assign({}, extraOutputs.staticFiles, extraOutputs.functions);
|
|
120
|
-
}
|
|
121
|
-
return { routes, output };
|
|
122
|
-
}
|
|
123
|
-
exports.createBuildOutput = createBuildOutput;
|