@modern-js/builder 2.8.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 +29 -0
- package/dist/plugins/asset.js +5 -2
- package/dist/plugins/splitChunks.d.ts +1 -1
- package/dist/plugins/splitChunks.js +10 -5
- package/dist/plugins/svg.js +8 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @modern-js/builder
|
|
2
2
|
|
|
3
|
+
## 2.10.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [a8db932]
|
|
8
|
+
- Updated dependencies [92d247f]
|
|
9
|
+
- Updated dependencies [0da32d0]
|
|
10
|
+
- Updated dependencies [0d9962b]
|
|
11
|
+
- Updated dependencies [fbefa7e]
|
|
12
|
+
- Updated dependencies [4d54233]
|
|
13
|
+
- Updated dependencies [6db4864]
|
|
14
|
+
- @modern-js/builder-shared@2.10.0
|
|
15
|
+
- @modern-js/utils@2.10.0
|
|
16
|
+
|
|
17
|
+
## 2.9.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- f31a254d78: feat: improve vendor split chunk rule
|
|
22
|
+
feat: 优化针对第三方库的拆包策略
|
|
23
|
+
- 1f047183c3: feat: enable svgo to avoid ID conflicts
|
|
24
|
+
feat: 启用 svgo 以避免 ID 冲突
|
|
25
|
+
- da66232feb: fix: asset url using incorrect path seperator in windows
|
|
26
|
+
|
|
27
|
+
fix: 修复 windows 中 asset url 使用错误的路径分隔符
|
|
28
|
+
|
|
29
|
+
- @modern-js/builder-shared@2.9.0
|
|
30
|
+
- @modern-js/utils@2.9.0
|
|
31
|
+
|
|
3
32
|
## 2.8.0
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/plugins/asset.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.builderAssetPlugin = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
5
8
|
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
6
9
|
const builderAssetPlugin = (assetType, exts) => ({
|
|
7
10
|
name: `builder-plugin-${assetType}`,
|
|
@@ -16,7 +19,7 @@ const builderAssetPlugin = (assetType, exts) => ({
|
|
|
16
19
|
(0, builder_shared_1.chainStaticAssetRule)({
|
|
17
20
|
rule,
|
|
18
21
|
maxSize,
|
|
19
|
-
filename:
|
|
22
|
+
filename: path_1.default.posix.join(distDir, filename),
|
|
20
23
|
assetType,
|
|
21
24
|
});
|
|
22
25
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
/** Expect to match path just like "./node_modules/react-router/" */
|
|
3
|
-
export declare const createDependenciesRegExp: (...dependencies: string[]) => RegExp;
|
|
3
|
+
export declare const createDependenciesRegExp: (...dependencies: (string | RegExp)[]) => RegExp;
|
|
4
4
|
export declare function builderPluginSplitChunks(): DefaultBuilderPlugin;
|
|
@@ -43,8 +43,13 @@ function getUserDefinedCacheGroups(forceSplitting) {
|
|
|
43
43
|
});
|
|
44
44
|
return cacheGroups;
|
|
45
45
|
}
|
|
46
|
+
const DEPENDENCY_MATCH_TEMPL = /[\\/]node_modules[\\/](<SOURCES>)[\\/]/.source;
|
|
46
47
|
/** Expect to match path just like "./node_modules/react-router/" */
|
|
47
|
-
const createDependenciesRegExp = (...dependencies) =>
|
|
48
|
+
const createDependenciesRegExp = (...dependencies) => {
|
|
49
|
+
const sources = dependencies.map(d => (typeof d === 'string' ? d : d.source));
|
|
50
|
+
const expr = DEPENDENCY_MATCH_TEMPL.replace('<SOURCES>', sources.join('|'));
|
|
51
|
+
return new RegExp(expr);
|
|
52
|
+
};
|
|
48
53
|
exports.createDependenciesRegExp = createDependenciesRegExp;
|
|
49
54
|
async function splitByExperience(ctx) {
|
|
50
55
|
const { isPackageInstalled } = await Promise.resolve().then(() => __importStar(require('@modern-js/utils')));
|
|
@@ -52,7 +57,7 @@ async function splitByExperience(ctx) {
|
|
|
52
57
|
const experienceCacheGroup = {};
|
|
53
58
|
const packageRegExps = {
|
|
54
59
|
react: (0, exports.createDependenciesRegExp)('react', 'react-dom'),
|
|
55
|
-
router: (0, exports.createDependenciesRegExp)('react-router', 'react-router-dom', 'history'),
|
|
60
|
+
router: (0, exports.createDependenciesRegExp)('react-router', 'react-router-dom', '@remix-run/router', 'history'),
|
|
56
61
|
lodash: (0, exports.createDependenciesRegExp)('lodash', 'lodash-es'),
|
|
57
62
|
};
|
|
58
63
|
// Detect if the package is installed in current project
|
|
@@ -61,13 +66,13 @@ async function splitByExperience(ctx) {
|
|
|
61
66
|
packageRegExps.antd = (0, exports.createDependenciesRegExp)('antd');
|
|
62
67
|
}
|
|
63
68
|
if (isPackageInstalled('@arco-design/web-react', rootPath)) {
|
|
64
|
-
packageRegExps.arco = (0, exports.createDependenciesRegExp)(
|
|
69
|
+
packageRegExps.arco = (0, exports.createDependenciesRegExp)(/@?arco-design/);
|
|
65
70
|
}
|
|
66
71
|
if (isPackageInstalled('@douyinfe/semi-ui', rootPath)) {
|
|
67
|
-
packageRegExps.semi = (0, exports.createDependenciesRegExp)(
|
|
72
|
+
packageRegExps.semi = (0, exports.createDependenciesRegExp)(/@(ies|douyinfe)[\\/]semi-.*/);
|
|
68
73
|
}
|
|
69
74
|
if (polyfill === 'entry' || polyfill === 'usage') {
|
|
70
|
-
packageRegExps.polyfill = (0, exports.createDependenciesRegExp)('core-js', '@babel/runtime');
|
|
75
|
+
packageRegExps.polyfill = (0, exports.createDependenciesRegExp)('core-js', '@babel/runtime', '@swc/helpers');
|
|
71
76
|
}
|
|
72
77
|
Object.entries(packageRegExps).forEach(([name, test]) => {
|
|
73
78
|
const key = `lib-${name}`;
|
package/dist/plugins/svg.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.builderPluginSvg = exports.getCompiledPath = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
5
8
|
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
6
|
-
const getCompiledPath = (packageName) =>
|
|
9
|
+
const getCompiledPath = (packageName) => path_1.default.join(__dirname, '../../compiled', packageName);
|
|
7
10
|
exports.getCompiledPath = getCompiledPath;
|
|
8
11
|
const builderPluginSvg = () => {
|
|
9
12
|
return {
|
|
@@ -15,14 +18,14 @@ const builderPluginSvg = () => {
|
|
|
15
18
|
const assetType = 'svg';
|
|
16
19
|
const distDir = (0, builder_shared_1.getDistPath)(config.output, 'svg');
|
|
17
20
|
const filename = (0, builder_shared_1.getFilename)(config.output, 'svg', isProd);
|
|
18
|
-
const outputName =
|
|
21
|
+
const outputName = path_1.default.posix.join(distDir, filename);
|
|
19
22
|
const maxSize = config.output.dataUriLimit[assetType];
|
|
20
23
|
const rule = chain.module.rule(CHAIN_ID.RULE.SVG).test(builder_shared_1.SVG_REGEX);
|
|
21
24
|
// If we import SVG from a CSS file, it will be processed as assets.
|
|
22
25
|
(0, builder_shared_1.chainStaticAssetRule)({
|
|
23
26
|
rule,
|
|
24
27
|
maxSize,
|
|
25
|
-
filename:
|
|
28
|
+
filename: path_1.default.posix.join(distDir, filename),
|
|
26
29
|
assetType,
|
|
27
30
|
issuer: {
|
|
28
31
|
// The issuer option ensures that SVGR will only apply if the SVG is imported from a JS file.
|
|
@@ -54,7 +57,7 @@ const builderPluginSvg = () => {
|
|
|
54
57
|
.type('javascript/auto')
|
|
55
58
|
.use(CHAIN_ID.USE.SVGR)
|
|
56
59
|
.loader(require.resolve('@svgr/webpack'))
|
|
57
|
-
.options({ svgo:
|
|
60
|
+
.options({ svgo: true })
|
|
58
61
|
.end()
|
|
59
62
|
.when(defaultExport === 'url', c => c
|
|
60
63
|
.use(CHAIN_ID.USE.URL)
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14.0.0"
|
|
16
16
|
},
|
|
17
|
-
"version": "2.
|
|
17
|
+
"version": "2.10.0",
|
|
18
18
|
"jsnext:source": "./src/index.ts",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@svgr/webpack": "6.5.1",
|
|
30
|
-
"@modern-js/builder-shared": "2.
|
|
31
|
-
"@modern-js/utils": "2.
|
|
30
|
+
"@modern-js/builder-shared": "2.10.0",
|
|
31
|
+
"@modern-js/utils": "2.10.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@babel/core": "7.18.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@types/babel__preset-env": "^7.9.2",
|
|
37
37
|
"@types/node": "^14",
|
|
38
38
|
"typescript": "^4",
|
|
39
|
-
"@scripts/vitest-config": "2.
|
|
39
|
+
"@scripts/vitest-config": "2.10.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"registry": "https://registry.npmjs.org/",
|