framework-for-react 1.0.8 → 1.0.10

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/README.md CHANGED
@@ -74,6 +74,16 @@ module.exports = webpackConfig;
74
74
  }
75
75
  ```
76
76
 
77
+ ### add split chunks
78
+ auto split
79
+
80
+ /node_modules/(react|react-dom|react-router|react-redux) => react-core.xxx.js
81
+ /node_modules/(antd|ant-design|element|echarts|zrender) => ui-lib.xxx.js
82
+ /node_modules/(axios|lodash|dayjs|classnames|react-intl) => utils.xxx.js
83
+ /node_modules/ => vendors.xxx.js
84
+
85
+ /src/(pages|views)/* => pages.xxx.js
86
+ /src/components/* => components.xxx.js
77
87
 
78
88
 
79
89
 
package/babel.config.js CHANGED
@@ -7,7 +7,7 @@ const config = {
7
7
  plugins: [
8
8
  '@babel/plugin-transform-arrow-functions',
9
9
  ['@babel/plugin-proposal-decorators', { legacy: true }],
10
- ['@babel/plugin-proposal-private-methods' /*, { loose: true }*/],
10
+ ['@babel/plugin-transform-private-methods' /*, { loose: true }*/],
11
11
  ['@babel/plugin-transform-class-properties' /*, { loose: true }*/],
12
12
  ],
13
13
  compact: false,
package/index.js CHANGED
@@ -21,15 +21,6 @@ const webpackConfig = {
21
21
  devtool: devMode,
22
22
  entry: {
23
23
  [entryPoint]: [path.join(APP_SRC, '/main.js')],
24
- vendors: [
25
- 'react',
26
- 'react-dom',
27
- 'react-redux',
28
- 'react-router-dom',
29
- 'axios',
30
- 'react-intl',
31
- 'classnames'
32
- ]
33
24
  },
34
25
  output: {
35
26
  path: APP_DIST,
@@ -100,9 +91,68 @@ const webpackConfig = {
100
91
  optimization: {
101
92
  splitChunks: {
102
93
  chunks: 'all',
103
- minSize: 256 * 1024,
104
- maxSize: 1280 * 1024
105
- }
94
+ minSize: 200 * 1024, // 最小200KB才拆分(太小不拆)
95
+ minChunks: 1,
96
+ maxAsyncRequests: 30,
97
+ maxInitialRequests: 30,
98
+ cacheGroups: {
99
+ // ======================================
100
+ // 🔥 核心:把第三方包 拆成几个中等大小的包
101
+ // 不会太大、不会太碎、加载最快
102
+ // ======================================
103
+ reactCore: {
104
+ name: 'react-core',
105
+ test: /[\\/]node_modules[\\/](react|react-dom|react-router|react-redux)[\\/]/,
106
+ priority: 20,
107
+ chunks: 'all',
108
+ enforce: true,
109
+ },
110
+
111
+ uiLib: {
112
+ name: 'ui-lib',
113
+ test: /[\\/]node_modules[\\/](antd|ant-design|element|echarts|zrender)[\\/]/,
114
+ priority: 19,
115
+ chunks: 'all',
116
+ enforce: true,
117
+ },
118
+
119
+ utils: {
120
+ name: 'utils',
121
+ test: /[\\/]node_modules[\\/](axios|lodash|dayjs|classnames|react-intl)[\\/]/,
122
+ priority: 18,
123
+ chunks: 'all',
124
+ enforce: true,
125
+ },
126
+
127
+ vendors: {
128
+ name: 'vendors',
129
+ test: /[\\/]node_modules[\\/]/,
130
+ priority: 10,
131
+ chunks: 'all',
132
+ },
133
+
134
+ // 页面分包
135
+ pages: {
136
+ name: 'pages',
137
+ test: /[\\/](pages|views)[\\/]/,
138
+ priority: 5,
139
+ chunks: 'all',
140
+ enforce: true,
141
+ },
142
+
143
+ // 组件分包
144
+ components: {
145
+ name: 'components',
146
+ test: /[\\/]components[\\/]/,
147
+ priority: 5,
148
+ chunks: 'all',
149
+ enforce: true,
150
+ },
151
+
152
+ default: false,
153
+ },
154
+ },
155
+ runtimeChunk: { name: 'runtime' }
106
156
  },
107
157
  plugins: [
108
158
  new MiniCssExtractPlugin({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "framework-for-react",
3
- "version": "1.0.8",
4
- "description": "framework for react18",
3
+ "version": "1.0.10",
4
+ "description": "framework for react18, update split chunks rules",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -24,10 +24,10 @@
24
24
  "dependencies": {
25
25
  "@babel/core": "^7.29.0",
26
26
  "@babel/plugin-proposal-decorators": "^7.29.0",
27
- "@babel/plugin-proposal-private-methods": "^7.18.6",
28
27
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
29
28
  "@babel/plugin-syntax-jsx": "^7.28.6",
30
29
  "@babel/plugin-transform-class-properties": "^7.28.6",
30
+ "@babel/plugin-transform-private-methods": "^7.28.6",
31
31
  "@babel/plugin-transform-runtime": "^7.29.0",
32
32
  "@babel/preset-env": "^7.29.0",
33
33
  "@babel/preset-react": "^7.28.5",