@modern-js/builder 2.22.1 → 2.23.1
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 +58 -0
- package/dist/plugins/assetsRetry.js +6 -1
- package/dist/plugins/index.js +2 -0
- package/dist/plugins/moment.d.ts +2 -0
- package/dist/plugins/moment.js +23 -0
- package/dist/plugins/splitChunks.js +15 -2
- package/dist/plugins/wasm.d.ts +2 -0
- package/dist/plugins/wasm.js +35 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @modern-js/builder
|
|
2
2
|
|
|
3
|
+
## 2.23.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 20c85bb: feat(rspack-provider): support performance.removeMomentLocale in rspack
|
|
8
|
+
|
|
9
|
+
feat(rspack-provider): 在使用 rspack 构建时支持 performance.removeMomentLocale 配置项
|
|
10
|
+
|
|
11
|
+
- 5772927: feat(rspack-provider): support import .wasm assets
|
|
12
|
+
|
|
13
|
+
feat(rspack-provider): 支持引用 .wasm 资源
|
|
14
|
+
|
|
15
|
+
- 8f2cab0: feat(builder): support using new URL to handle wasm assets
|
|
16
|
+
|
|
17
|
+
feat(builder): 支持通过 new URL 来处理 wasm 资源
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [f08bbfc]
|
|
20
|
+
- Updated dependencies [a6b313a]
|
|
21
|
+
- Updated dependencies [5772927]
|
|
22
|
+
- Updated dependencies [811ccd4]
|
|
23
|
+
- Updated dependencies [5a3eeff]
|
|
24
|
+
- Updated dependencies [4d4dca0]
|
|
25
|
+
- Updated dependencies [8f2cab0]
|
|
26
|
+
- @modern-js/utils@2.23.1
|
|
27
|
+
- @modern-js/builder-shared@2.23.1
|
|
28
|
+
|
|
29
|
+
## 2.23.0
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- 9b270b6: feat(builder): extend rules of splitByExperience
|
|
34
|
+
feat(builder): 拓展 splitByExperience 内部规则
|
|
35
|
+
- 7e6fb5f: chore: publishConfig add provenance config
|
|
36
|
+
|
|
37
|
+
chore: publishConfig 增加 provenance 配置
|
|
38
|
+
|
|
39
|
+
- 692cc0e: fix(builder): assetsRetry.crossOrigin default to html.crossorigin
|
|
40
|
+
|
|
41
|
+
fix(builder): assetsRetry.crossOrigin 默认值与 html.crossorigin 保持一致
|
|
42
|
+
|
|
43
|
+
- a82d6f7: fix(builder): single-vendor chunkSplit not work as expected
|
|
44
|
+
|
|
45
|
+
fix(builder): single-vendor 拆包规则未按照预期生效
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [15eac36]
|
|
48
|
+
- Updated dependencies [d4e85c1]
|
|
49
|
+
- Updated dependencies [7e6fb5f]
|
|
50
|
+
- Updated dependencies [a7a7ad7]
|
|
51
|
+
- Updated dependencies [6dec7c2]
|
|
52
|
+
- Updated dependencies [c3216b5]
|
|
53
|
+
- Updated dependencies [f14f920]
|
|
54
|
+
- Updated dependencies [692cc0e]
|
|
55
|
+
- Updated dependencies [38eccef]
|
|
56
|
+
- Updated dependencies [f91c557]
|
|
57
|
+
- Updated dependencies [a82d6f7]
|
|
58
|
+
- @modern-js/builder-shared@2.23.0
|
|
59
|
+
- @modern-js/utils@2.23.0
|
|
60
|
+
|
|
3
61
|
## 2.22.1
|
|
4
62
|
|
|
5
63
|
### Patch Changes
|
|
@@ -36,9 +36,14 @@ function builderPluginAssetsRetry() {
|
|
|
36
36
|
}
|
|
37
37
|
const { AssetsRetryPlugin } = await Promise.resolve().then(() => __importStar(require('@modern-js/builder-shared')));
|
|
38
38
|
const distDir = (0, builder_shared_1.getDistPath)(config.output, 'js');
|
|
39
|
+
const { assetsRetry = {} } = config.output;
|
|
40
|
+
// assetsRetry.crossOrigin should be same as html.crossorigin by default
|
|
41
|
+
if (assetsRetry.crossOrigin === undefined) {
|
|
42
|
+
assetsRetry.crossOrigin = config.html.crossorigin;
|
|
43
|
+
}
|
|
39
44
|
chain.plugin(CHAIN_ID.PLUGIN.ASSETS_RETRY).use(AssetsRetryPlugin, [
|
|
40
45
|
{
|
|
41
|
-
...
|
|
46
|
+
...assetsRetry,
|
|
42
47
|
distDir,
|
|
43
48
|
HtmlPlugin,
|
|
44
49
|
},
|
package/dist/plugins/index.js
CHANGED
|
@@ -49,4 +49,6 @@ exports.plugins = {
|
|
|
49
49
|
tsChecker: () => Promise.resolve().then(() => __importStar(require('./tsChecker'))).then(m => m.builderPluginTsChecker()),
|
|
50
50
|
checkSyntax: () => Promise.resolve().then(() => __importStar(require('./checkSyntax'))).then(m => m.builderPluginCheckSyntax()),
|
|
51
51
|
rem: () => Promise.resolve().then(() => __importStar(require('./rem'))).then(m => m.builderPluginRem()),
|
|
52
|
+
wasm: () => Promise.resolve().then(() => __importStar(require('./wasm'))).then(m => m.builderPluginWasm()),
|
|
53
|
+
moment: () => Promise.resolve().then(() => __importStar(require('./moment'))).then(m => m.builderPluginMoment()),
|
|
52
54
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.builderPluginMoment = void 0;
|
|
4
|
+
const builderPluginMoment = () => ({
|
|
5
|
+
name: 'builder-plugin-moment',
|
|
6
|
+
setup(api) {
|
|
7
|
+
api.modifyBundlerChain(async (chain, { webpack }) => {
|
|
8
|
+
const config = api.getNormalizedConfig();
|
|
9
|
+
if (config.performance.removeMomentLocale) {
|
|
10
|
+
// Moment.js includes a lots of locale data by default.
|
|
11
|
+
// We can using IgnorePlugin to allow the user to opt into importing specific locales.
|
|
12
|
+
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
13
|
+
chain.plugin('remove-moment-locale').use(webpack.IgnorePlugin, [
|
|
14
|
+
{
|
|
15
|
+
resourceRegExp: /^\.\/locale$/,
|
|
16
|
+
contextRegExp: /moment$/,
|
|
17
|
+
},
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
exports.builderPluginMoment = builderPluginMoment;
|
|
@@ -61,6 +61,7 @@ async function splitByExperience(ctx) {
|
|
|
61
61
|
react: (0, exports.createDependenciesRegExp)('react', 'react-dom'),
|
|
62
62
|
router: (0, exports.createDependenciesRegExp)('react-router', 'react-router-dom', '@remix-run/router', 'history'),
|
|
63
63
|
lodash: (0, exports.createDependenciesRegExp)('lodash', 'lodash-es'),
|
|
64
|
+
axios: (0, exports.createDependenciesRegExp)('axios', /axios-.+/),
|
|
64
65
|
};
|
|
65
66
|
// Detect if the package is installed in current project
|
|
66
67
|
// If installed, add the package to cache group
|
|
@@ -113,7 +114,7 @@ function splitByModule(ctx) {
|
|
|
113
114
|
// Core group
|
|
114
115
|
vendors: {
|
|
115
116
|
priority: -10,
|
|
116
|
-
test:
|
|
117
|
+
test: builder_shared_1.NODE_MODULES_REGEX,
|
|
117
118
|
// todo: not support in rspack
|
|
118
119
|
name(module) {
|
|
119
120
|
return (0, builder_shared_1.getPackageNameFromModulePath)(module.context);
|
|
@@ -161,14 +162,26 @@ function allInOne(_ctx) {
|
|
|
161
162
|
}
|
|
162
163
|
// Ignore user defined cache group to get single vendor chunk.
|
|
163
164
|
function singleVendor(ctx) {
|
|
164
|
-
const { override, defaultConfig } = ctx;
|
|
165
|
+
const { override, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
165
166
|
(0, assert_1.default)(defaultConfig !== false);
|
|
166
167
|
(0, assert_1.default)(override !== false);
|
|
168
|
+
const singleVendorCacheGroup = {
|
|
169
|
+
singleVendor: {
|
|
170
|
+
test: builder_shared_1.NODE_MODULES_REGEX,
|
|
171
|
+
priority: 0,
|
|
172
|
+
chunks: 'all',
|
|
173
|
+
name: 'vendor',
|
|
174
|
+
enforce: true,
|
|
175
|
+
reuseExistingChunk: true,
|
|
176
|
+
},
|
|
177
|
+
};
|
|
167
178
|
return {
|
|
168
179
|
...defaultConfig,
|
|
169
180
|
...override,
|
|
170
181
|
cacheGroups: {
|
|
171
182
|
...defaultConfig.cacheGroups,
|
|
183
|
+
...singleVendorCacheGroup,
|
|
184
|
+
...userDefinedCacheGroups,
|
|
172
185
|
...override.cacheGroups,
|
|
173
186
|
},
|
|
174
187
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.builderPluginWasm = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const builder_shared_1 = require("@modern-js/builder-shared");
|
|
6
|
+
const builderPluginWasm = () => ({
|
|
7
|
+
name: 'builder-plugin-wasm',
|
|
8
|
+
setup(api) {
|
|
9
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
10
|
+
const config = api.getNormalizedConfig();
|
|
11
|
+
const distPath = (0, builder_shared_1.getDistPath)(config.output, 'wasm');
|
|
12
|
+
chain.experiments({
|
|
13
|
+
...chain.get('experiments'),
|
|
14
|
+
asyncWebAssembly: true,
|
|
15
|
+
});
|
|
16
|
+
const wasmFilename = (0, path_1.join)(distPath, '[hash].module.wasm');
|
|
17
|
+
chain.output.merge({
|
|
18
|
+
webassemblyModuleFilename: wasmFilename,
|
|
19
|
+
});
|
|
20
|
+
// support new URL('./xx.wasm', import.meta.url)
|
|
21
|
+
chain.module
|
|
22
|
+
.rule(CHAIN_ID.RULE.WASM)
|
|
23
|
+
.test(/\.wasm$/)
|
|
24
|
+
// only include assets that came from new URL calls
|
|
25
|
+
.merge({
|
|
26
|
+
dependency: 'url',
|
|
27
|
+
})
|
|
28
|
+
.type('asset/resource')
|
|
29
|
+
.set('generator', {
|
|
30
|
+
filename: wasmFilename,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
exports.builderPluginWasm = builderPluginWasm;
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=14.0.0"
|
|
20
20
|
},
|
|
21
|
-
"version": "2.
|
|
21
|
+
"version": "2.23.1",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -31,18 +31,19 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@svgr/webpack": "8.0.1",
|
|
34
|
-
"@modern-js/builder-shared": "2.
|
|
35
|
-
"@modern-js/utils": "2.
|
|
34
|
+
"@modern-js/builder-shared": "2.23.1",
|
|
35
|
+
"@modern-js/utils": "2.23.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/babel__core": "^7.20.0",
|
|
39
39
|
"@types/node": "^14",
|
|
40
40
|
"typescript": "^5",
|
|
41
|
-
"@scripts/vitest-config": "2.
|
|
41
|
+
"@scripts/vitest-config": "2.23.1"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"registry": "https://registry.npmjs.org/",
|
|
45
|
-
"access": "public"
|
|
45
|
+
"access": "public",
|
|
46
|
+
"provenance": true
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"new": "modern new",
|