@modern-js/builder 2.23.0 → 2.24.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 +40 -0
- package/dist/plugins/externals.d.ts +2 -0
- package/dist/plugins/externals.js +28 -0
- package/dist/plugins/html.js +0 -2
- package/dist/plugins/index.js +3 -0
- package/dist/plugins/moment.d.ts +2 -0
- package/dist/plugins/moment.js +23 -0
- package/dist/plugins/wasm.d.ts +2 -0
- package/dist/plugins/wasm.js +35 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
# @modern-js/builder
|
|
2
2
|
|
|
3
|
+
## 2.24.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ef041c0: chore(builder): reuse externals plugin
|
|
8
|
+
|
|
9
|
+
chore(builder): 复用 externals 插件
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [c882fbd]
|
|
12
|
+
- Updated dependencies [ef041c0]
|
|
13
|
+
- Updated dependencies [4a82c3b]
|
|
14
|
+
- @modern-js/utils@2.24.0
|
|
15
|
+
- @modern-js/builder-shared@2.24.0
|
|
16
|
+
|
|
17
|
+
## 2.23.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 20c85bb: feat(rspack-provider): support performance.removeMomentLocale in rspack
|
|
22
|
+
|
|
23
|
+
feat(rspack-provider): 在使用 rspack 构建时支持 performance.removeMomentLocale 配置项
|
|
24
|
+
|
|
25
|
+
- 5772927: feat(rspack-provider): support import .wasm assets
|
|
26
|
+
|
|
27
|
+
feat(rspack-provider): 支持引用 .wasm 资源
|
|
28
|
+
|
|
29
|
+
- 8f2cab0: feat(builder): support using new URL to handle wasm assets
|
|
30
|
+
|
|
31
|
+
feat(builder): 支持通过 new URL 来处理 wasm 资源
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [f08bbfc]
|
|
34
|
+
- Updated dependencies [a6b313a]
|
|
35
|
+
- Updated dependencies [5772927]
|
|
36
|
+
- Updated dependencies [811ccd4]
|
|
37
|
+
- Updated dependencies [5a3eeff]
|
|
38
|
+
- Updated dependencies [4d4dca0]
|
|
39
|
+
- Updated dependencies [8f2cab0]
|
|
40
|
+
- @modern-js/utils@2.23.1
|
|
41
|
+
- @modern-js/builder-shared@2.23.1
|
|
42
|
+
|
|
3
43
|
## 2.23.0
|
|
4
44
|
|
|
5
45
|
### Patch Changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.builderPluginExternals = void 0;
|
|
4
|
+
function builderPluginExternals() {
|
|
5
|
+
return {
|
|
6
|
+
name: 'builder-plugin-externals',
|
|
7
|
+
setup(api) {
|
|
8
|
+
api.modifyBundlerChain(chain => {
|
|
9
|
+
const { externals } = api.getNormalizedConfig().output;
|
|
10
|
+
if (externals) {
|
|
11
|
+
chain.externals(externals);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
|
15
|
+
bundlerConfigs.forEach(config => {
|
|
16
|
+
const isWebWorker = Array.isArray(config.target)
|
|
17
|
+
? config.target.includes('webworker')
|
|
18
|
+
: config.target === 'webworker';
|
|
19
|
+
// externals will not take effect, the Worker environment can not access global variables.
|
|
20
|
+
if (isWebWorker && config.externals) {
|
|
21
|
+
delete config.externals;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.builderPluginExternals = builderPluginExternals;
|
package/dist/plugins/html.js
CHANGED
|
@@ -184,8 +184,6 @@ const builderPluginHtml = () => ({
|
|
|
184
184
|
.use(HtmlCrossOriginPlugin, [
|
|
185
185
|
{ crossOrigin: formattedCrossorigin, HtmlPlugin },
|
|
186
186
|
]);
|
|
187
|
-
// todo: not support in rspack
|
|
188
|
-
// @ts-expect-error
|
|
189
187
|
chain.output.crossOriginLoading(formattedCrossorigin);
|
|
190
188
|
}
|
|
191
189
|
if (faviconUrls.length) {
|
package/dist/plugins/index.js
CHANGED
|
@@ -49,4 +49,7 @@ 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()),
|
|
54
|
+
externals: () => Promise.resolve().then(() => __importStar(require('./externals'))).then(m => m.builderPluginExternals()),
|
|
52
55
|
};
|
|
@@ -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;
|
|
@@ -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.24.0",
|
|
22
22
|
"jsnext:source": "./src/index.ts",
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"main": "./dist/index.js",
|
|
@@ -31,14 +31,14 @@
|
|
|
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.24.0",
|
|
35
|
+
"@modern-js/utils": "2.24.0"
|
|
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.24.0"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"registry": "https://registry.npmjs.org/",
|