@umijs/bundler-utils 4.0.11 → 4.0.14

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.
Files changed (2) hide show
  1. package/dist/https.js +14 -5
  2. package/package.json +3 -2
package/dist/https.js CHANGED
@@ -66,9 +66,10 @@ async function resolveHttpsConfig(httpsConfig) {
66
66
  throw new Error(`[HTTPS] mkcert not found.`);
67
67
  }
68
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)) {
69
+ key = (0, import_path.join)(__dirname, "umi.https.key.pem");
70
+ cert = (0, import_path.join)(__dirname, "umi.https.pem");
71
+ const json = (0, import_path.join)(__dirname, "umi.https.json");
72
+ if (!(0, import_fs.existsSync)(key) || !(0, import_fs.existsSync)(cert) || !(0, import_fs.existsSync)(json) || !hasHostsChanged(json, hosts)) {
72
73
  import_utils.logger.wait("[HTTPS] Generating cert and key files...");
73
74
  await import_utils.execa.execa("mkcert", [
74
75
  "-cert-file",
@@ -77,20 +78,28 @@ async function resolveHttpsConfig(httpsConfig) {
77
78
  key,
78
79
  ...hosts
79
80
  ]);
81
+ (0, import_fs.writeFileSync)(json, JSON.stringify({ hosts }), "utf-8");
80
82
  }
81
83
  return {
82
84
  key,
83
85
  cert
84
86
  };
85
87
  }
88
+ function hasHostsChanged(jsonFile, hosts) {
89
+ try {
90
+ const json = JSON.parse((0, import_fs.readFileSync)(jsonFile, "utf-8"));
91
+ return json.hosts.join(",") === hosts.join(",");
92
+ } catch (e) {
93
+ return true;
94
+ }
95
+ }
86
96
  async function createHttpsServer(app, httpsConfig) {
87
97
  import_utils.logger.wait("[HTTPS] Starting service in https mode...");
88
98
  const { key, cert } = await resolveHttpsConfig(httpsConfig);
89
- const http2Service = import_spdy.default.createServer({
99
+ return import_spdy.default.createServer({
90
100
  key: (0, import_fs.readFileSync)(key, "utf-8"),
91
101
  cert: (0, import_fs.readFileSync)(cert, "utf-8")
92
102
  }, app);
93
- return http2Service;
94
103
  }
95
104
  // Annotate the CommonJS export names for ESM import in node:
96
105
  0 && (module.exports = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-utils",
3
- "version": "4.0.11",
3
+ "version": "4.0.14",
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": {
@@ -20,8 +20,9 @@
20
20
  "dev": "umi-scripts father dev"
21
21
  },
22
22
  "dependencies": {
23
- "@umijs/utils": "4.0.11",
23
+ "@umijs/utils": "4.0.14",
24
24
  "esbuild": "0.14.49",
25
+ "regenerate": "^1.4.2",
25
26
  "regenerate-unicode-properties": "10.0.1",
26
27
  "spdy": "^4.0.2"
27
28
  },