@umijs/bundler-utils 4.0.8 → 4.0.9

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
File without changes
package/dist/https.js CHANGED
@@ -35,8 +35,15 @@ var defaultHttpsHosts = [
35
35
  "127.0.0.1"
36
36
  ];
37
37
  async function resolveHttpsConfig(httpsConfig) {
38
+ let { key, cert, hosts } = httpsConfig;
39
+ if (key && cert) {
40
+ return {
41
+ key,
42
+ cert
43
+ };
44
+ }
38
45
  try {
39
- await import_utils.execa.execa("mkcert", ["--version"]);
46
+ await import_utils.execa.execa("mkcert", ["-help"]);
40
47
  } catch (e) {
41
48
  import_utils.logger.error("[HTTPS] The mkcert has not been installed.");
42
49
  import_utils.logger.info("[HTTPS] Please follow the guide to install manually.");
@@ -58,12 +65,9 @@ async function resolveHttpsConfig(httpsConfig) {
58
65
  }
59
66
  throw new Error(`[HTTPS] mkcert not found.`);
60
67
  }
61
- let { key, cert, hosts } = httpsConfig;
62
68
  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
- }
69
+ key = (0, import_path.join)(__dirname, "umi.key.pem");
70
+ cert = (0, import_path.join)(__dirname, "umi.pem");
67
71
  if (!(0, import_fs.existsSync)(key) || !(0, import_fs.existsSync)(cert)) {
68
72
  import_utils.logger.wait("[HTTPS] Generating cert and key files...");
69
73
  await import_utils.execa.execa("mkcert", [
package/dist/index.d.ts CHANGED
File without changes
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  parseModuleSync: () => parseModuleSync
26
26
  });
27
27
  module.exports = __toCommonJS(src_exports);
28
+ var import_code_frame = require("@umijs/bundler-utils/compiled/babel/code-frame");
28
29
  var import_es_module_lexer = require("@umijs/bundler-utils/compiled/es-module-lexer");
29
30
  var import_esbuild = require("@umijs/bundler-utils/compiled/esbuild");
30
31
  var import_utils = require("@umijs/utils");
@@ -38,10 +39,15 @@ async function parseModule(opts) {
38
39
  function parseModuleSync(opts) {
39
40
  let content = opts.content;
40
41
  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;
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`);
50
+ }
45
51
  }
46
52
  return (0, import_es_module_lexer.parse)(content);
47
53
  }
@@ -49,6 +55,26 @@ function isDepPath(path) {
49
55
  const umiMonorepoPaths = ["umi/packages/", "umi-next/packages/"];
50
56
  return path.includes("node_modules") || umiMonorepoPaths.some((p) => (0, import_utils.winPath)(path).includes(p));
51
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
+ }
77
+ }
52
78
  // Annotate the CommonJS export names for ESM import in node:
53
79
  0 && (module.exports = {
54
80
  isDepPath,
package/dist/types.d.ts CHANGED
File without changes
package/dist/types.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-utils",
3
- "version": "4.0.8",
3
+ "version": "4.0.9",
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": "pnpm father build",
18
+ "build": "umi-scripts father build",
19
19
  "build:deps": "umi-scripts bundleDeps",
20
- "dev": "pnpm father dev"
20
+ "dev": "umi-scripts father dev"
21
21
  },
22
22
  "dependencies": {
23
- "@umijs/utils": "4.0.8",
24
- "esbuild": "0.14.36",
23
+ "@umijs/utils": "4.0.9",
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.16.7",
30
- "@babel/core": "7.17.9",
31
- "@babel/generator": "7.17.9",
32
- "@babel/helper-module-imports": "7.16.7",
33
- "@babel/parser": "7.17.9",
34
- "@babel/plugin-proposal-decorators": "7.17.9",
35
- "@babel/plugin-proposal-do-expressions": "7.16.7",
36
- "@babel/plugin-proposal-export-default-from": "7.16.7",
37
- "@babel/plugin-proposal-export-namespace-from": "7.16.7",
38
- "@babel/plugin-proposal-function-bind": "7.16.7",
39
- "@babel/plugin-proposal-partial-application": "7.16.7",
40
- "@babel/plugin-proposal-pipeline-operator": "7.17.6",
41
- "@babel/plugin-proposal-record-and-tuple": "7.16.7",
42
- "@babel/plugin-transform-runtime": "7.17.0",
43
- "@babel/preset-env": "7.16.11",
44
- "@babel/preset-react": "7.16.7",
45
- "@babel/preset-typescript": "7.16.7",
46
- "@babel/register": "7.17.7",
47
- "@babel/template": "7.16.7",
48
- "@babel/traverse": "7.17.9",
49
- "@babel/types": "7.17.0",
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",