@modern-js/utils 1.9.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 1.15.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 8658a78: chore: remove `@modern-js/plugin-docsite`
8
+
9
+ chore: 移除 `@modern-js/plugin-docsite`
10
+
11
+ - 05d4a4f: chore(utils): add fs-extra to exports fields
12
+
13
+ chore(utils): 通过 exports 导出 fs-extra 子路径
14
+
15
+ - ad05af9: fix: bff.proxy and devServer.proxy types
16
+
17
+ fix: 修复 bff.proxy 和 devServer.proxy 类型定义不完整的问题
18
+
19
+ - 5d53d1c: fix(webpack): failed to format error message in some cases
20
+
21
+ fix(webpack): 修复格式化 webpack 错误信息时报错的问题
22
+
23
+ - 37cd159: feat(webpack): log more detailed error messages
24
+
3
25
  ## 1.9.0
4
26
 
5
27
  ### Minor Changes
package/dist/chainId.d.ts CHANGED
@@ -13,6 +13,12 @@ export declare const CHAIN_ID: {
13
13
  readonly JS: "js";
14
14
  /** Rule for ts */
15
15
  readonly TS: "ts";
16
+ /** Rule for css */
17
+ readonly CSS: "css";
18
+ /** Rule for less */
19
+ readonly LESS: "less";
20
+ /** Rule for sass */
21
+ readonly SASS: "sass";
16
22
  };
17
23
  /** Predefined rule groups */
18
24
  readonly ONE_OF: {
@@ -42,6 +48,10 @@ export declare const CHAIN_ID: {
42
48
  readonly TS: "ts";
43
49
  /** css-loader */
44
50
  readonly CSS: "css";
51
+ /** sass-loader */
52
+ readonly SASS: "sass";
53
+ /** less-loader */
54
+ readonly LESS: "less";
45
55
  /** url-loader */
46
56
  readonly URL: "url";
47
57
  /** file-loader */
package/dist/chainId.js CHANGED
@@ -16,6 +16,12 @@ exports.CHAIN_ID = {
16
16
  JS: 'js',
17
17
  /** Rule for ts */
18
18
  TS: 'ts',
19
+ /** Rule for css */
20
+ CSS: 'css',
21
+ /** Rule for less */
22
+ LESS: 'less',
23
+ /** Rule for sass */
24
+ SASS: 'sass',
19
25
  },
20
26
  /** Predefined rule groups */
21
27
  ONE_OF: {
@@ -45,6 +51,10 @@ exports.CHAIN_ID = {
45
51
  TS: 'ts',
46
52
  /** css-loader */
47
53
  CSS: 'css',
54
+ /** sass-loader */
55
+ SASS: 'sass',
56
+ /** less-loader */
57
+ LESS: 'less',
48
58
  /** url-loader */
49
59
  URL: 'url',
50
60
  /** file-loader */
package/dist/constants.js CHANGED
@@ -72,7 +72,6 @@ exports.INTERNAL_PLUGINS = {
72
72
  '@modern-js/plugin-electron': { cli: '@modern-js/plugin-electron/cli' },
73
73
  '@modern-js/plugin-testing': { cli: '@modern-js/plugin-testing/cli' },
74
74
  '@modern-js/plugin-storybook': { cli: '@modern-js/plugin-storybook/cli' },
75
- '@modern-js/plugin-docsite': { cli: '@modern-js/plugin-docsite/cli' },
76
75
  '@modern-js/plugin-express': {
77
76
  cli: '@modern-js/plugin-express/cli',
78
77
  server: '@modern-js/plugin-express',
package/dist/format.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * LICENSE file at
6
6
  * https://github.com/facebook/create-react-app/blob/master/LICENSE
7
7
  */
8
- import { StatsCompilation } from 'webpack';
8
+ import type { StatsCompilation } from 'webpack';
9
9
  import type { ProxyDetail, BffProxyOptions } from '@modern-js/types';
10
10
  declare function formatWebpackMessages(json: StatsCompilation): {
11
11
  errors: string[];
package/dist/format.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable no-param-reassign */
3
2
  /**
4
3
  * Copyright (c) 2015-present, Facebook, Inc.
5
4
  *
@@ -9,22 +8,26 @@
9
8
  */
10
9
  Object.defineProperty(exports, "__esModule", { value: true });
11
10
  exports.formatProxyOptions = exports.formatWebpackMessages = void 0;
12
- const friendlySyntaxErrorLabel = 'Syntax error:';
11
+ const friendlySyntaxErrorLabel = 'SyntaxError:';
13
12
  function isLikelyASyntaxError(message) {
14
13
  return message.includes(friendlySyntaxErrorLabel);
15
14
  }
16
15
  // Cleans up webpack error messages.
17
- function formatMessage(message) {
18
- var _a;
16
+ function formatMessage(stats) {
19
17
  let lines = [];
18
+ let message;
20
19
  // webpack 5 stats error object
21
- if (typeof message === 'object') {
22
- message = `${(message.moduleName && `${message.moduleName}\n`)}${message.details || message.stack || message.message}`;
20
+ if (typeof stats === 'object') {
21
+ const fileName = stats.moduleName ? `File: ${stats.moduleName}\n` : '';
22
+ const mainMessage = stats.message;
23
+ const details = stats.details ? `\nDetails: ${stats.details}\n` : '';
24
+ const stack = stats.stack ? `\n${stats.stack}` : '';
25
+ message = `${fileName}${mainMessage}${details}${stack}`;
26
+ }
27
+ else {
28
+ message = stats;
23
29
  }
24
30
  lines = message.split('\n');
25
- // Strip webpack-added headers off errors/warnings
26
- // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
27
- lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line));
28
31
  // Transform parsing error into syntax error
29
32
  lines = lines.map(line => {
30
33
  const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
@@ -45,15 +48,8 @@ function formatMessage(message) {
45
48
  // Clean up file name
46
49
  lines[0] = lines[0].replace(/^(.*) \d+:\d+-\d+$/, '$1');
47
50
  // Cleans up verbose "module not found" messages for files and packages.
48
- if ((_a = lines[1]) === null || _a === void 0 ? void 0 : _a.startsWith('Module not found: ')) {
49
- lines = [
50
- lines[0],
51
- lines[1]
52
- .replace('Error: ', '')
53
- .replace('Module not found: Cannot find file:', 'Cannot find file:')
54
- .replace('[CaseSensitivePathsPlugin] ', '')
55
- .replace("Cannot resolve 'file' or 'directory' ", ''),
56
- ];
51
+ if (lines[1] && lines[1].indexOf('Module not found:') !== -1) {
52
+ lines[1] = lines[1].replace('Error: ', '');
57
53
  }
58
54
  message = lines.join('\n');
59
55
  // Internal stacks are generally useless so we strip them... with the
@@ -90,7 +86,6 @@ function formatWebpackMessages(json) {
90
86
  return result;
91
87
  }
92
88
  exports.formatWebpackMessages = formatWebpackMessages;
93
- /* eslint-enable no-param-reassign */
94
89
  function formatProxyOptions(proxyOptions) {
95
90
  const formattedProxy = [];
96
91
  if (!Array.isArray(proxyOptions)) {
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.9.0",
14
+ "version": "1.15.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -30,6 +30,7 @@
30
30
  "./semver": "./compiled/semver/index.js",
31
31
  "./lodash": "./compiled/lodash/index.js",
32
32
  "./globby": "./compiled/globby/index.js",
33
+ "./fs-extra": "./compiled/fs-extra/index.js",
33
34
  "./fast-glob": "./compiled/fast-glob/index.js",
34
35
  "./gzip-size": "./compiled/gzip-size/index.js",
35
36
  "./mime-types": "./compiled/mime-types/index.js",
@@ -38,7 +39,8 @@
38
39
  "./browserslist": "./compiled/browserslist/index.js",
39
40
  "./webpack-chain": "./compiled/webpack-chain/index.js",
40
41
  "./tsconfig-paths": "./compiled/tsconfig-paths/index.js",
41
- "./better-ajv-errors": "./compiled/better-ajv-errors/index.js"
42
+ "./better-ajv-errors": "./compiled/better-ajv-errors/index.js",
43
+ "./chain-id": "./dist/chainId.js"
42
44
  },
43
45
  "publishConfig": {
44
46
  "registry": "https://registry.npmjs.org/",
@@ -79,6 +81,9 @@
79
81
  "globby": [
80
82
  "./compiled/globby/index.d.ts"
81
83
  ],
84
+ "fs-extra": [
85
+ "./compiled/fs-extra/index.d.ts"
86
+ ],
82
87
  "fast-glob": [
83
88
  "./compiled/fast-glob/index.d.ts"
84
89
  ],
@@ -105,6 +110,9 @@
105
110
  ],
106
111
  "better-ajv-errors": [
107
112
  "./compiled/better-ajv-errors/index.d.ts"
113
+ ],
114
+ "chain-id": [
115
+ "./dist/chainId.d.ts"
108
116
  ]
109
117
  }
110
118
  },
@@ -113,9 +121,9 @@
113
121
  "lodash": "^4.17.21"
114
122
  },
115
123
  "devDependencies": {
116
- "@modern-js/types": "1.6.2",
117
- "@scripts/build": "0.0.0",
118
- "@scripts/jest-config": "0.0.0",
124
+ "@modern-js/types": "1.15.0",
125
+ "@scripts/build": "1.15.0",
126
+ "@scripts/jest-config": "1.15.0",
119
127
  "@types/jest": "^27",
120
128
  "@types/node": "^14",
121
129
  "typescript": "^4",