@shuvi/toolpack 1.0.26 → 1.0.28

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.
@@ -35,7 +35,8 @@ const base_1 = require("./base");
35
35
  const style_1 = require("./parts/style");
36
36
  const helpers_1 = require("./parts/helpers");
37
37
  const BIG_LIBRARY_THRESHOLD = 160000; // byte
38
- const SHUVI_PKGS_REGEX = /[\\/]node_modules[\\/]@shuvi[\\/]/;
38
+ const SHUVI_PKGS_REGEX = /[\\/]node_modules[\\/](@shuvi|doura)[\\/]/;
39
+ const NODE_MODULES_REGEXP = /[\\/]node_modules[\\/]/i;
39
40
  const FRAMEWORK_REACT_MODULES = [
40
41
  {
41
42
  test: /[/\\]node_modules[/\\]react[/\\]/
@@ -96,11 +97,34 @@ function createBrowserWebpackChain(options) {
96
97
  chain.plugin('private/hmr-plugin').use(webpack_1.default.HotModuleReplacementPlugin);
97
98
  }
98
99
  else {
100
+ const getDefaultChunkName = (_module, chunks) => {
101
+ return crypto
102
+ .createHash('sha1')
103
+ .update(chunks.reduce((acc, chunk) => {
104
+ return acc + chunk.name;
105
+ }, ''))
106
+ .digest('hex')
107
+ .substring(0, 8);
108
+ };
99
109
  chain.optimization.splitChunks({
100
110
  chunks: helpers_1.splitChunksFilter,
101
111
  cacheGroups: {
102
- default: false,
103
- defaultVendors: false,
112
+ default: {
113
+ name: getDefaultChunkName,
114
+ filename: (0, helpers_1.commonChunkFilename)({ dev: false }),
115
+ idHint: '',
116
+ reuseExistingChunk: true,
117
+ minChunks: 2,
118
+ priority: -20
119
+ },
120
+ defaultVendors: {
121
+ name: getDefaultChunkName,
122
+ filename: (0, helpers_1.commonChunkFilename)({ dev: false }),
123
+ idHint: 'vendors',
124
+ reuseExistingChunk: true,
125
+ test: NODE_MODULES_REGEXP,
126
+ priority: -10
127
+ },
104
128
  framework: {
105
129
  chunks: 'all',
106
130
  name: 'framework',
@@ -144,7 +168,7 @@ function createBrowserWebpackChain(options) {
144
168
  lib: {
145
169
  test(module) {
146
170
  return (module.size() > BIG_LIBRARY_THRESHOLD &&
147
- /[/\\]node_modules[/\\]/.test(module.nameForCondition() || ''));
171
+ NODE_MODULES_REGEXP.test(module.nameForCondition() || ''));
148
172
  },
149
173
  name(module) {
150
174
  const hash = crypto.createHash('sha1');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/toolpack",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -20,7 +20,7 @@
20
20
  "node": ">= 16.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@shuvi/compiler": "1.0.26",
23
+ "@shuvi/compiler": "1.0.28",
24
24
  "@babel/core": "7.12.10",
25
25
  "@babel/plugin-proposal-class-properties": "7.12.1",
26
26
  "@babel/plugin-proposal-nullish-coalescing-operator": "7.10.1",
@@ -35,8 +35,8 @@
35
35
  "@babel/preset-typescript": "7.12.7",
36
36
  "@babel/runtime": "7.12.5",
37
37
  "lightningcss": "1.19.0",
38
- "@shuvi/shared": "1.0.26",
39
- "@shuvi/utils": "1.0.26",
38
+ "@shuvi/shared": "1.0.28",
39
+ "@shuvi/utils": "1.0.28",
40
40
  "babel-loader": "8.2.2",
41
41
  "babel-plugin-syntax-jsx": "6.18.0",
42
42
  "babel-plugin-transform-define": "2.0.0",