@umijs/bundler-utils 4.0.7 → 4.0.10
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/compiled/@babel/core/index.d.ts +30 -2
- package/compiled/@babel/generator/index.d.ts +0 -1
- package/compiled/@babel/parser/typings/babel-parser.d.ts +12 -1
- package/compiled/@babel/traverse/index.d.ts +16 -9
- package/compiled/@babel/types/lib/index-legacy.d.ts +88 -48
- package/compiled/babel/index.js +101236 -132421
- package/dist/https.d.ts +0 -1
- package/dist/https.js +91 -67
- package/dist/index.js +75 -37
- package/dist/types.js +17 -2
- package/package.json +29 -27
package/dist/https.d.ts
CHANGED
package/dist/https.js
CHANGED
|
@@ -1,75 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
4
10
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/https.ts
|
|
23
|
+
var https_exports = {};
|
|
24
|
+
__export(https_exports, {
|
|
25
|
+
createHttpsServer: () => createHttpsServer,
|
|
26
|
+
resolveHttpsConfig: () => resolveHttpsConfig
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(https_exports);
|
|
29
|
+
var import_utils = require("@umijs/utils");
|
|
30
|
+
var import_fs = require("fs");
|
|
31
|
+
var import_path = require("path");
|
|
32
|
+
var import_spdy = __toESM(require("spdy"));
|
|
33
|
+
var defaultHttpsHosts = [
|
|
34
|
+
"localhost",
|
|
35
|
+
"127.0.0.1"
|
|
14
36
|
];
|
|
15
|
-
// vite mode requires a key cert
|
|
16
37
|
async function resolveHttpsConfig(httpsConfig) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await utils_1.execa.execa('mkcert', ['--version']);
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
utils_1.logger.error('[HTTPS] The mkcert has not been installed.');
|
|
23
|
-
utils_1.logger.info('[HTTPS] Please follow the guide to install manually.');
|
|
24
|
-
switch (process.platform) {
|
|
25
|
-
case 'darwin':
|
|
26
|
-
console.log(utils_1.chalk.green('$ brew install mkcert'));
|
|
27
|
-
console.log(utils_1.chalk.gray('# If you use firefox, please install nss.'));
|
|
28
|
-
console.log(utils_1.chalk.green('$ brew install nss'));
|
|
29
|
-
console.log(utils_1.chalk.green('$ mkcert -install'));
|
|
30
|
-
break;
|
|
31
|
-
case 'win32':
|
|
32
|
-
console.log(utils_1.chalk.green('Checkout https://github.com/FiloSottile/mkcert#windows'));
|
|
33
|
-
break;
|
|
34
|
-
case 'linux':
|
|
35
|
-
console.log(utils_1.chalk.green('Checkout https://github.com/FiloSottile/mkcert#linux'));
|
|
36
|
-
break;
|
|
37
|
-
default:
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
throw new Error(`[HTTPS] mkcert not found.`);
|
|
41
|
-
}
|
|
42
|
-
let { key, cert, hosts } = httpsConfig;
|
|
43
|
-
hosts = hosts || defaultHttpsHosts;
|
|
44
|
-
if (!key || !cert) {
|
|
45
|
-
key = (0, path_1.join)(__dirname, 'umi.key.pem');
|
|
46
|
-
cert = (0, path_1.join)(__dirname, 'umi.pem');
|
|
47
|
-
}
|
|
48
|
-
// Generate cert and key files if they are not exist.
|
|
49
|
-
if (!(0, fs_1.existsSync)(key) || !(0, fs_1.existsSync)(cert)) {
|
|
50
|
-
utils_1.logger.wait('[HTTPS] Generating cert and key files...');
|
|
51
|
-
await utils_1.execa.execa('mkcert', [
|
|
52
|
-
'-cert-file',
|
|
53
|
-
cert,
|
|
54
|
-
'-key-file',
|
|
55
|
-
key,
|
|
56
|
-
...hosts,
|
|
57
|
-
]);
|
|
58
|
-
}
|
|
38
|
+
let { key, cert, hosts } = httpsConfig;
|
|
39
|
+
if (key && cert) {
|
|
59
40
|
return {
|
|
60
|
-
|
|
61
|
-
|
|
41
|
+
key,
|
|
42
|
+
cert
|
|
62
43
|
};
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await import_utils.execa.execa("mkcert", ["-help"]);
|
|
47
|
+
} catch (e) {
|
|
48
|
+
import_utils.logger.error("[HTTPS] The mkcert has not been installed.");
|
|
49
|
+
import_utils.logger.info("[HTTPS] Please follow the guide to install manually.");
|
|
50
|
+
switch (process.platform) {
|
|
51
|
+
case "darwin":
|
|
52
|
+
console.log(import_utils.chalk.green("$ brew install mkcert"));
|
|
53
|
+
console.log(import_utils.chalk.gray("# If you use firefox, please install nss."));
|
|
54
|
+
console.log(import_utils.chalk.green("$ brew install nss"));
|
|
55
|
+
console.log(import_utils.chalk.green("$ mkcert -install"));
|
|
56
|
+
break;
|
|
57
|
+
case "win32":
|
|
58
|
+
console.log(import_utils.chalk.green("Checkout https://github.com/FiloSottile/mkcert#windows"));
|
|
59
|
+
break;
|
|
60
|
+
case "linux":
|
|
61
|
+
console.log(import_utils.chalk.green("Checkout https://github.com/FiloSottile/mkcert#linux"));
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`[HTTPS] mkcert not found.`);
|
|
67
|
+
}
|
|
68
|
+
hosts = hosts || defaultHttpsHosts;
|
|
69
|
+
key = (0, import_path.join)(__dirname, "umi.key.pem");
|
|
70
|
+
cert = (0, import_path.join)(__dirname, "umi.pem");
|
|
71
|
+
if (!(0, import_fs.existsSync)(key) || !(0, import_fs.existsSync)(cert)) {
|
|
72
|
+
import_utils.logger.wait("[HTTPS] Generating cert and key files...");
|
|
73
|
+
await import_utils.execa.execa("mkcert", [
|
|
74
|
+
"-cert-file",
|
|
75
|
+
cert,
|
|
76
|
+
"-key-file",
|
|
77
|
+
key,
|
|
78
|
+
...hosts
|
|
79
|
+
]);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
key,
|
|
83
|
+
cert
|
|
84
|
+
};
|
|
63
85
|
}
|
|
64
|
-
exports.resolveHttpsConfig = resolveHttpsConfig;
|
|
65
86
|
async function createHttpsServer(app, httpsConfig) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return http2Service;
|
|
87
|
+
import_utils.logger.wait("[HTTPS] Starting service in https mode...");
|
|
88
|
+
const { key, cert } = await resolveHttpsConfig(httpsConfig);
|
|
89
|
+
const http2Service = import_spdy.default.createServer({
|
|
90
|
+
key: (0, import_fs.readFileSync)(key, "utf-8"),
|
|
91
|
+
cert: (0, import_fs.readFileSync)(cert, "utf-8")
|
|
92
|
+
}, app);
|
|
93
|
+
return http2Service;
|
|
74
94
|
}
|
|
75
|
-
|
|
95
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
96
|
+
0 && (module.exports = {
|
|
97
|
+
createHttpsServer,
|
|
98
|
+
resolveHttpsConfig
|
|
99
|
+
});
|
package/dist/index.js
CHANGED
|
@@ -1,45 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
15
16
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
isDepPath: () => isDepPath,
|
|
24
|
+
parseModule: () => parseModule,
|
|
25
|
+
parseModuleSync: () => parseModuleSync
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
var import_code_frame = require("@umijs/bundler-utils/compiled/babel/code-frame");
|
|
29
|
+
var import_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
|
|
30
|
+
var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
|
|
31
|
+
var import_utils = require("@umijs/utils");
|
|
32
|
+
var import_path = require("path");
|
|
33
|
+
__reExport(src_exports, require("./https"), module.exports);
|
|
34
|
+
__reExport(src_exports, require("./types"), module.exports);
|
|
22
35
|
async function parseModule(opts) {
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
await import_es_module_lexer.init;
|
|
37
|
+
return parseModuleSync(opts);
|
|
25
38
|
}
|
|
26
|
-
exports.parseModule = parseModule;
|
|
27
39
|
function parseModuleSync(opts) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
let content = opts.content;
|
|
41
|
+
if (opts.path.endsWith(".tsx") || opts.path.endsWith(".jsx")) {
|
|
42
|
+
try {
|
|
43
|
+
content = (0, import_esbuild.transformSync)(content, {
|
|
44
|
+
loader: (0, import_path.extname)(opts.path).slice(1),
|
|
45
|
+
format: "esm"
|
|
46
|
+
}).code;
|
|
47
|
+
} catch (e) {
|
|
48
|
+
prettyPrintEsBuildErrors(e.errors, opts);
|
|
49
|
+
throw Error(`transform ${opts.path} failed`);
|
|
34
50
|
}
|
|
35
|
-
|
|
51
|
+
}
|
|
52
|
+
return (0, import_es_module_lexer.parse)(content);
|
|
36
53
|
}
|
|
37
|
-
exports.parseModuleSync = parseModuleSync;
|
|
38
54
|
function isDepPath(path) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
const umiMonorepoPaths = ["umi/packages/", "umi-next/packages/"];
|
|
56
|
+
return path.includes("node_modules") || umiMonorepoPaths.some((p) => (0, import_utils.winPath)(path).includes(p));
|
|
57
|
+
}
|
|
58
|
+
function prettyPrintEsBuildErrors(errors = [], opts) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
for (const error of errors) {
|
|
61
|
+
if (((_a = error.location) == null ? void 0 : _a.line) && ((_b = error.location) == null ? void 0 : _b.column)) {
|
|
62
|
+
const message = (0, import_code_frame.codeFrameColumns)(opts.content, {
|
|
63
|
+
start: {
|
|
64
|
+
line: error.location.line,
|
|
65
|
+
column: error.location.column
|
|
66
|
+
}
|
|
67
|
+
}, {
|
|
68
|
+
message: error.text,
|
|
69
|
+
highlightCode: true
|
|
70
|
+
});
|
|
71
|
+
console.log(`
|
|
72
|
+
${opts.path}:
|
|
73
|
+
${message}
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
42
77
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
isDepPath,
|
|
81
|
+
parseModule,
|
|
82
|
+
parseModuleSync
|
|
83
|
+
});
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
14
|
+
|
|
15
|
+
// src/types.ts
|
|
16
|
+
var types_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(types_exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-utils",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.10",
|
|
4
4
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-utils#readme",
|
|
5
5
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
6
6
|
"repository": {
|
|
@@ -15,39 +15,40 @@
|
|
|
15
15
|
"compiled"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "
|
|
18
|
+
"build": "umi-scripts father build",
|
|
19
19
|
"build:deps": "umi-scripts bundleDeps",
|
|
20
|
-
"dev": "
|
|
20
|
+
"dev": "umi-scripts father dev"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@umijs/utils": "4.0.
|
|
24
|
-
"esbuild": "0.14.
|
|
23
|
+
"@umijs/utils": "4.0.10",
|
|
24
|
+
"esbuild": "0.14.49",
|
|
25
25
|
"regenerate-unicode-properties": "10.0.1",
|
|
26
26
|
"spdy": "^4.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@babel/code-frame": "7.
|
|
30
|
-
"@babel/core": "7.
|
|
31
|
-
"@babel/generator": "7.
|
|
32
|
-
"@babel/helper-module-imports": "7.
|
|
33
|
-
"@babel/parser": "7.
|
|
34
|
-
"@babel/plugin-proposal-decorators": "7.
|
|
35
|
-
"@babel/plugin-proposal-do-expressions": "7.
|
|
36
|
-
"@babel/plugin-proposal-export-default-from": "7.
|
|
37
|
-
"@babel/plugin-proposal-export-namespace-from": "7.
|
|
38
|
-
"@babel/plugin-proposal-function-bind": "7.
|
|
39
|
-
"@babel/plugin-proposal-partial-application": "7.
|
|
40
|
-
"@babel/plugin-proposal-pipeline-operator": "7.
|
|
41
|
-
"@babel/plugin-proposal-record-and-tuple": "7.
|
|
42
|
-
"@babel/plugin-transform-runtime": "7.
|
|
43
|
-
"@babel/preset-env": "7.
|
|
44
|
-
"@babel/preset-react": "7.
|
|
45
|
-
"@babel/preset-typescript": "7.
|
|
46
|
-
"@babel/register": "7.
|
|
47
|
-
"@babel/template": "7.
|
|
48
|
-
"@babel/traverse": "7.
|
|
49
|
-
"@babel/types": "7.
|
|
29
|
+
"@babel/code-frame": "7.18.6",
|
|
30
|
+
"@babel/core": "7.18.9",
|
|
31
|
+
"@babel/generator": "7.18.9",
|
|
32
|
+
"@babel/helper-module-imports": "7.18.6",
|
|
33
|
+
"@babel/parser": "7.18.9",
|
|
34
|
+
"@babel/plugin-proposal-decorators": "7.18.9",
|
|
35
|
+
"@babel/plugin-proposal-do-expressions": "7.18.6",
|
|
36
|
+
"@babel/plugin-proposal-export-default-from": "7.18.9",
|
|
37
|
+
"@babel/plugin-proposal-export-namespace-from": "7.18.9",
|
|
38
|
+
"@babel/plugin-proposal-function-bind": "7.18.9",
|
|
39
|
+
"@babel/plugin-proposal-partial-application": "7.18.9",
|
|
40
|
+
"@babel/plugin-proposal-pipeline-operator": "7.18.9",
|
|
41
|
+
"@babel/plugin-proposal-record-and-tuple": "7.18.6",
|
|
42
|
+
"@babel/plugin-transform-runtime": "7.18.9",
|
|
43
|
+
"@babel/preset-env": "7.18.9",
|
|
44
|
+
"@babel/preset-react": "7.18.6",
|
|
45
|
+
"@babel/preset-typescript": "7.18.6",
|
|
46
|
+
"@babel/register": "7.18.9",
|
|
47
|
+
"@babel/template": "7.18.6",
|
|
48
|
+
"@babel/traverse": "7.18.9",
|
|
49
|
+
"@babel/types": "7.18.9",
|
|
50
50
|
"@types/babel__code-frame": "7.0.3",
|
|
51
|
+
"@types/babel__core": "7.1.19",
|
|
51
52
|
"@types/babel__generator": "7.6.4",
|
|
52
53
|
"@types/babel__parser": "7.1.1",
|
|
53
54
|
"@types/babel__template": "7.4.1",
|
|
@@ -83,7 +84,8 @@
|
|
|
83
84
|
"es-module-lexer": "$$LOCAL",
|
|
84
85
|
"express": "$$LOCAL",
|
|
85
86
|
"less": "$$LOCAL",
|
|
86
|
-
"tapable": "$$LOCAL"
|
|
87
|
+
"tapable": "$$LOCAL",
|
|
88
|
+
"regenerate": "regenerate"
|
|
87
89
|
},
|
|
88
90
|
"noMinify": [
|
|
89
91
|
"./bundles/babel/bundle"
|