@modern-js/builder 2.23.0 → 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 CHANGED
@@ -1,5 +1,31 @@
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
+
3
29
  ## 2.23.0
4
30
 
5
31
  ### Patch Changes
@@ -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,2 @@
1
+ import { DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
+ export declare const builderPluginMoment: () => DefaultBuilderPlugin;
@@ -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,2 @@
1
+ import { type DefaultBuilderPlugin } from '@modern-js/builder-shared';
2
+ export declare const builderPluginWasm: () => DefaultBuilderPlugin;
@@ -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.23.0",
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,14 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@svgr/webpack": "8.0.1",
34
- "@modern-js/builder-shared": "2.23.0",
35
- "@modern-js/utils": "2.23.0"
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.23.0"
41
+ "@scripts/vitest-config": "2.23.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "registry": "https://registry.npmjs.org/",