@umijs/bundler-utils 4.0.5 → 4.0.8

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/https.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
- /// <reference types="node" />
3
2
  import { RequestListener } from 'http';
4
3
  import { HttpsServerOptions } from './types';
5
4
  export type { Server as SpdyServer } from 'spdy';
package/dist/https.js CHANGED
@@ -1,75 +1,95 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createHttpsServer = exports.resolveHttpsConfig = void 0;
7
- const utils_1 = require("@umijs/utils");
8
- const fs_1 = require("fs");
9
- const path_1 = require("path");
10
- const spdy_1 = __importDefault(require("spdy"));
11
- const defaultHttpsHosts = [
12
- 'localhost',
13
- '127.0.0.1',
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
+ // 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
- // Check if mkcert is installed
18
- try {
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
- ]);
38
+ try {
39
+ await import_utils.execa.execa("mkcert", ["--version"]);
40
+ } catch (e) {
41
+ import_utils.logger.error("[HTTPS] The mkcert has not been installed.");
42
+ import_utils.logger.info("[HTTPS] Please follow the guide to install manually.");
43
+ switch (process.platform) {
44
+ case "darwin":
45
+ console.log(import_utils.chalk.green("$ brew install mkcert"));
46
+ console.log(import_utils.chalk.gray("# If you use firefox, please install nss."));
47
+ console.log(import_utils.chalk.green("$ brew install nss"));
48
+ console.log(import_utils.chalk.green("$ mkcert -install"));
49
+ break;
50
+ case "win32":
51
+ console.log(import_utils.chalk.green("Checkout https://github.com/FiloSottile/mkcert#windows"));
52
+ break;
53
+ case "linux":
54
+ console.log(import_utils.chalk.green("Checkout https://github.com/FiloSottile/mkcert#linux"));
55
+ break;
56
+ default:
57
+ break;
58
58
  }
59
- return {
60
- key,
61
- cert,
62
- };
59
+ throw new Error(`[HTTPS] mkcert not found.`);
60
+ }
61
+ let { key, cert, hosts } = httpsConfig;
62
+ hosts = hosts || defaultHttpsHosts;
63
+ if (!key || !cert) {
64
+ key = (0, import_path.join)(__dirname, "umi.key.pem");
65
+ cert = (0, import_path.join)(__dirname, "umi.pem");
66
+ }
67
+ if (!(0, import_fs.existsSync)(key) || !(0, import_fs.existsSync)(cert)) {
68
+ import_utils.logger.wait("[HTTPS] Generating cert and key files...");
69
+ await import_utils.execa.execa("mkcert", [
70
+ "-cert-file",
71
+ cert,
72
+ "-key-file",
73
+ key,
74
+ ...hosts
75
+ ]);
76
+ }
77
+ return {
78
+ key,
79
+ cert
80
+ };
63
81
  }
64
- exports.resolveHttpsConfig = resolveHttpsConfig;
65
82
  async function createHttpsServer(app, httpsConfig) {
66
- utils_1.logger.wait('[HTTPS] Starting service in https mode...');
67
- const { key, cert } = await resolveHttpsConfig(httpsConfig);
68
- // Create server
69
- const http2Service = spdy_1.default.createServer({
70
- key: (0, fs_1.readFileSync)(key, 'utf-8'),
71
- cert: (0, fs_1.readFileSync)(cert, 'utf-8'),
72
- }, app);
73
- return http2Service;
83
+ import_utils.logger.wait("[HTTPS] Starting service in https mode...");
84
+ const { key, cert } = await resolveHttpsConfig(httpsConfig);
85
+ const http2Service = import_spdy.default.createServer({
86
+ key: (0, import_fs.readFileSync)(key, "utf-8"),
87
+ cert: (0, import_fs.readFileSync)(cert, "utf-8")
88
+ }, app);
89
+ return http2Service;
74
90
  }
75
- exports.createHttpsServer = createHttpsServer;
91
+ // Annotate the CommonJS export names for ESM import in node:
92
+ 0 && (module.exports = {
93
+ createHttpsServer,
94
+ resolveHttpsConfig
95
+ });
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
@@ -1,45 +1,57 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
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 });
15
8
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isDepPath = exports.parseModuleSync = exports.parseModule = void 0;
18
- const es_module_lexer_1 = require("@umijs/bundler-utils/compiled/es-module-lexer");
19
- const esbuild_1 = require("@umijs/bundler-utils/compiled/esbuild");
20
- const utils_1 = require("@umijs/utils");
21
- const path_1 = require("path");
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;
16
+ };
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
+ // 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_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
29
+ var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
30
+ var import_utils = require("@umijs/utils");
31
+ var import_path = require("path");
32
+ __reExport(src_exports, require("./https"), module.exports);
33
+ __reExport(src_exports, require("./types"), module.exports);
22
34
  async function parseModule(opts) {
23
- await es_module_lexer_1.init;
24
- return parseModuleSync(opts);
35
+ await import_es_module_lexer.init;
36
+ return parseModuleSync(opts);
25
37
  }
26
- exports.parseModule = parseModule;
27
38
  function parseModuleSync(opts) {
28
- let content = opts.content;
29
- if (opts.path.endsWith('.tsx') || opts.path.endsWith('.jsx')) {
30
- content = (0, esbuild_1.transformSync)(content, {
31
- loader: (0, path_1.extname)(opts.path).slice(1),
32
- format: 'esm',
33
- }).code;
34
- }
35
- return (0, es_module_lexer_1.parse)(content);
39
+ let content = opts.content;
40
+ if (opts.path.endsWith(".tsx") || opts.path.endsWith(".jsx")) {
41
+ content = (0, import_esbuild.transformSync)(content, {
42
+ loader: (0, import_path.extname)(opts.path).slice(1),
43
+ format: "esm"
44
+ }).code;
45
+ }
46
+ return (0, import_es_module_lexer.parse)(content);
36
47
  }
37
- exports.parseModuleSync = parseModuleSync;
38
48
  function isDepPath(path) {
39
- const umiMonorepoPaths = ['umi/packages/', 'umi-next/packages/'];
40
- return (path.includes('node_modules') ||
41
- umiMonorepoPaths.some((p) => (0, utils_1.winPath)(path).includes(p)));
49
+ const umiMonorepoPaths = ["umi/packages/", "umi-next/packages/"];
50
+ return path.includes("node_modules") || umiMonorepoPaths.some((p) => (0, import_utils.winPath)(path).includes(p));
42
51
  }
43
- exports.isDepPath = isDepPath;
44
- __exportStar(require("./https"), exports);
45
- __exportStar(require("./types"), exports);
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ isDepPath,
55
+ parseModule,
56
+ parseModuleSync
57
+ });
package/dist/types.d.ts CHANGED
File without changes
package/dist/types.js CHANGED
@@ -1,2 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
+ // 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.5",
3
+ "version": "4.0.8",
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,12 +15,12 @@
15
15
  "compiled"
16
16
  ],
17
17
  "scripts": {
18
- "build": "pnpm tsc",
18
+ "build": "pnpm father build",
19
19
  "build:deps": "umi-scripts bundleDeps",
20
- "dev": "pnpm build --watch"
20
+ "dev": "pnpm father dev"
21
21
  },
22
22
  "dependencies": {
23
- "@umijs/utils": "4.0.5",
23
+ "@umijs/utils": "4.0.8",
24
24
  "esbuild": "0.14.36",
25
25
  "regenerate-unicode-properties": "10.0.1",
26
26
  "spdy": "^4.0.2"