@modern-js/utils 2.8.1-alpha.0 → 2.10.0
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/CHANGELOG.md +19 -0
- package/dist/babel.d.ts +3 -0
- package/dist/babel.js +136 -0
- package/dist/format.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/package.json +11 -7
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.10.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 0da32d0: chore: upgrade jest and puppeteer
|
8
|
+
chore: 升级 jest 和 puppeteer 到 latest
|
9
|
+
- fbefa7e: chore(deps): bump webpack from 5.75.0 to 5.76.2
|
10
|
+
|
11
|
+
chore(deps): 将 webpack 从 5.75.0 升级至 5.76.2
|
12
|
+
|
13
|
+
- 4d54233: chore(builder): update rspack & show rspack format error
|
14
|
+
|
15
|
+
chore(builder): 更新 rspack 版本 & 优化 rspack 错误日志输出
|
16
|
+
|
17
|
+
- 6db4864: feat: add output.splitRouteChunks
|
18
|
+
feat: 添加 output.splitRouteChunks 配置
|
19
|
+
|
20
|
+
## 2.9.0
|
21
|
+
|
3
22
|
## 2.8.0
|
4
23
|
|
5
24
|
### Patch Changes
|
package/dist/babel.d.ts
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
import { BabelConfig, BabelConfigUtils, BabelTransformOptions } from '@modern-js/types';
|
2
|
+
export declare const getBabelUtils: (config: BabelTransformOptions) => BabelConfigUtils;
|
3
|
+
export declare const applyUserBabelConfig: (defaultOptions: BabelTransformOptions, userBabelConfig?: BabelConfig | BabelConfig[], extraBabelUtils?: Partial<BabelConfigUtils>) => BabelTransformOptions;
|
package/dist/babel.js
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
8
|
+
var __spreadValues = (a, b) => {
|
9
|
+
for (var prop in b || (b = {}))
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
12
|
+
if (__getOwnPropSymbols)
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
14
|
+
if (__propIsEnum.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
}
|
17
|
+
return a;
|
18
|
+
};
|
19
|
+
var __export = (target, all) => {
|
20
|
+
for (var name in all)
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
22
|
+
};
|
23
|
+
var __copyProps = (to, from, except, desc) => {
|
24
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
25
|
+
for (let key of __getOwnPropNames(from))
|
26
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
27
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
28
|
+
}
|
29
|
+
return to;
|
30
|
+
};
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
32
|
+
var babel_exports = {};
|
33
|
+
__export(babel_exports, {
|
34
|
+
applyUserBabelConfig: () => applyUserBabelConfig,
|
35
|
+
getBabelUtils: () => getBabelUtils
|
36
|
+
});
|
37
|
+
module.exports = __toCommonJS(babel_exports);
|
38
|
+
var import_path = require("path");
|
39
|
+
var import_applyOptionsChain = require("./applyOptionsChain");
|
40
|
+
var import_ensureArray = require("./ensureArray");
|
41
|
+
var import_path2 = require("./path");
|
42
|
+
const formatPath = (originPath) => {
|
43
|
+
if ((0, import_path.isAbsolute)(originPath)) {
|
44
|
+
return originPath.split(import_path.sep).join("/");
|
45
|
+
}
|
46
|
+
return originPath;
|
47
|
+
};
|
48
|
+
const getPluginItemName = (item) => {
|
49
|
+
if (typeof item === "string") {
|
50
|
+
return formatPath(item);
|
51
|
+
}
|
52
|
+
if (Array.isArray(item) && typeof item[0] === "string") {
|
53
|
+
return formatPath(item[0]);
|
54
|
+
}
|
55
|
+
return null;
|
56
|
+
};
|
57
|
+
const addPlugins = (plugins, config) => {
|
58
|
+
if (config.plugins) {
|
59
|
+
config.plugins.push(...plugins);
|
60
|
+
} else {
|
61
|
+
config.plugins = plugins;
|
62
|
+
}
|
63
|
+
};
|
64
|
+
const addPresets = (presets, config) => {
|
65
|
+
if (config.presets) {
|
66
|
+
config.presets.push(...presets);
|
67
|
+
} else {
|
68
|
+
config.presets = presets;
|
69
|
+
}
|
70
|
+
};
|
71
|
+
const removePlugins = (plugins, config) => {
|
72
|
+
if (!config.plugins) {
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
const removeList = (0, import_ensureArray.ensureArray)(plugins);
|
76
|
+
config.plugins = config.plugins.filter((item) => {
|
77
|
+
const name = getPluginItemName(item);
|
78
|
+
if (name) {
|
79
|
+
return !removeList.find((removeItem) => name.includes(removeItem));
|
80
|
+
}
|
81
|
+
return true;
|
82
|
+
});
|
83
|
+
};
|
84
|
+
const removePresets = (presets, config) => {
|
85
|
+
if (!config.presets) {
|
86
|
+
return;
|
87
|
+
}
|
88
|
+
const removeList = (0, import_ensureArray.ensureArray)(presets);
|
89
|
+
config.presets = config.presets.filter((item) => {
|
90
|
+
const name = getPluginItemName(item);
|
91
|
+
if (name) {
|
92
|
+
return !removeList.find((removeItem) => name.includes(removeItem));
|
93
|
+
}
|
94
|
+
return true;
|
95
|
+
});
|
96
|
+
};
|
97
|
+
const modifyPresetOptions = (presetName, options, presets = []) => {
|
98
|
+
presets.forEach((preset, index) => {
|
99
|
+
if (Array.isArray(preset)) {
|
100
|
+
if (typeof preset[0] === "string" && (0, import_path2.normalizeToPosixPath)(preset[0]).includes(presetName)) {
|
101
|
+
preset[1] = __spreadValues(__spreadValues({}, preset[1] || {}), options);
|
102
|
+
}
|
103
|
+
} else if (typeof preset === "string" && (0, import_path2.normalizeToPosixPath)(preset).includes(presetName)) {
|
104
|
+
presets[index] = [preset, options];
|
105
|
+
}
|
106
|
+
});
|
107
|
+
};
|
108
|
+
const getBabelUtils = (config) => {
|
109
|
+
const noop = () => {
|
110
|
+
};
|
111
|
+
return {
|
112
|
+
addPlugins: (plugins) => addPlugins(plugins, config),
|
113
|
+
addPresets: (presets) => addPresets(presets, config),
|
114
|
+
removePlugins: (plugins) => removePlugins(plugins, config),
|
115
|
+
removePresets: (presets) => removePresets(presets, config),
|
116
|
+
// `addIncludes` and `addExcludes` are noop functions by default,
|
117
|
+
// It can be overridden by `extraBabelUtils`.
|
118
|
+
addIncludes: noop,
|
119
|
+
addExcludes: noop,
|
120
|
+
// Compat `presetEnvOptions` and `presetReactOptions` in Eden.
|
121
|
+
modifyPresetEnvOptions: (options) => modifyPresetOptions("@babel/preset-env", options, config.presets || []),
|
122
|
+
modifyPresetReactOptions: (options) => modifyPresetOptions("@babel/preset-react", options, config.presets || [])
|
123
|
+
};
|
124
|
+
};
|
125
|
+
const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
|
126
|
+
if (userBabelConfig) {
|
127
|
+
const babelUtils = __spreadValues(__spreadValues({}, getBabelUtils(defaultOptions)), extraBabelUtils);
|
128
|
+
return (0, import_applyOptionsChain.applyOptionsChain)(defaultOptions, userBabelConfig || {}, babelUtils);
|
129
|
+
}
|
130
|
+
return defaultOptions;
|
131
|
+
};
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
133
|
+
0 && (module.exports = {
|
134
|
+
applyUserBabelConfig,
|
135
|
+
getBabelUtils
|
136
|
+
});
|
package/dist/format.js
CHANGED
@@ -30,7 +30,7 @@ function formatMessage(stats) {
|
|
30
30
|
if (typeof stats === "object") {
|
31
31
|
const fileName = stats.moduleName ? `File: ${stats.moduleName}
|
32
32
|
` : "";
|
33
|
-
const mainMessage = stats.message;
|
33
|
+
const mainMessage = typeof stats.formatted === "string" ? stats.formatted : stats.message;
|
34
34
|
const details = stats.details ? `
|
35
35
|
Details: ${stats.details}
|
36
36
|
` : "";
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -58,3 +58,4 @@ __reExport(src_exports, require("./testUtils"), module.exports);
|
|
58
58
|
__reExport(src_exports, require("./getCoreJsVersion"), module.exports);
|
59
59
|
__reExport(src_exports, require("./react"), module.exports);
|
60
60
|
__reExport(src_exports, require("./getTargetDir"), module.exports);
|
61
|
+
__reExport(src_exports, require("./babel"), module.exports);
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.
|
14
|
+
"version": "2.10.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -26,6 +26,7 @@
|
|
26
26
|
"./serialize": "./dist/serialize.js",
|
27
27
|
"./nestedRoutes": "./dist/nestedRoutes.js",
|
28
28
|
"./remix-router": "./dist/remix-router.js",
|
29
|
+
"./babel": "./dist/babel.js",
|
29
30
|
"./ajv": "./compiled/ajv/index.js",
|
30
31
|
"./glob": "./compiled/glob/index.js",
|
31
32
|
"./chalk": "./compiled/chalk/index.js",
|
@@ -70,6 +71,9 @@
|
|
70
71
|
"nestedRoutes": [
|
71
72
|
"./dist/nestedRoutes.d.ts"
|
72
73
|
],
|
74
|
+
"babel": [
|
75
|
+
"./dist/babel.d.ts"
|
76
|
+
],
|
73
77
|
"ajv": [
|
74
78
|
"./compiled/ajv/types/ajv.d.ts"
|
75
79
|
],
|
@@ -161,15 +165,15 @@
|
|
161
165
|
"react": ">=17.0.0",
|
162
166
|
"react-dom": ">=17.0.0",
|
163
167
|
"react-router-dom": "^6.8.1",
|
164
|
-
"@types/jest": "^
|
168
|
+
"@types/jest": "^29",
|
165
169
|
"@types/node": "^14",
|
166
|
-
"jest": "^
|
170
|
+
"jest": "^29",
|
167
171
|
"typescript": "^4",
|
168
|
-
"webpack": "^5.
|
172
|
+
"webpack": "^5.76.2",
|
169
173
|
"@types/serialize-javascript": "^5.0.1",
|
170
|
-
"@modern-js/types": "2.
|
171
|
-
"@scripts/
|
172
|
-
"@scripts/
|
174
|
+
"@modern-js/types": "2.10.0",
|
175
|
+
"@scripts/jest-config": "2.10.0",
|
176
|
+
"@scripts/build": "2.10.0"
|
173
177
|
},
|
174
178
|
"sideEffects": false,
|
175
179
|
"scripts": {
|