@modern-js/builder 2.22.1 → 2.23.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 CHANGED
@@ -1,5 +1,37 @@
1
1
  # @modern-js/builder
2
2
 
3
+ ## 2.23.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 9b270b6: feat(builder): extend rules of splitByExperience
8
+ feat(builder): 拓展 splitByExperience 内部规则
9
+ - 7e6fb5f: chore: publishConfig add provenance config
10
+
11
+ chore: publishConfig 增加 provenance 配置
12
+
13
+ - 692cc0e: fix(builder): assetsRetry.crossOrigin default to html.crossorigin
14
+
15
+ fix(builder): assetsRetry.crossOrigin 默认值与 html.crossorigin 保持一致
16
+
17
+ - a82d6f7: fix(builder): single-vendor chunkSplit not work as expected
18
+
19
+ fix(builder): single-vendor 拆包规则未按照预期生效
20
+
21
+ - Updated dependencies [15eac36]
22
+ - Updated dependencies [d4e85c1]
23
+ - Updated dependencies [7e6fb5f]
24
+ - Updated dependencies [a7a7ad7]
25
+ - Updated dependencies [6dec7c2]
26
+ - Updated dependencies [c3216b5]
27
+ - Updated dependencies [f14f920]
28
+ - Updated dependencies [692cc0e]
29
+ - Updated dependencies [38eccef]
30
+ - Updated dependencies [f91c557]
31
+ - Updated dependencies [a82d6f7]
32
+ - @modern-js/builder-shared@2.23.0
33
+ - @modern-js/utils@2.23.0
34
+
3
35
  ## 2.22.1
4
36
 
5
37
  ### 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
- ...(config.output.assetsRetry || {}),
46
+ ...assetsRetry,
42
47
  distDir,
43
48
  HtmlPlugin,
44
49
  },
@@ -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: /[\\/]node_modules[\\/]/,
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
  };
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  "engines": {
19
19
  "node": ">=14.0.0"
20
20
  },
21
- "version": "2.22.1",
21
+ "version": "2.23.0",
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.22.1",
35
- "@modern-js/utils": "2.22.1"
34
+ "@modern-js/builder-shared": "2.23.0",
35
+ "@modern-js/utils": "2.23.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.22.1"
41
+ "@scripts/vitest-config": "2.23.0"
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",