@s-ui/bundler 9.79.0-beta.1 → 9.79.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "9.79.0-beta.1",
3
+ "version": "9.79.0-beta.3",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -1,25 +1,49 @@
1
1
  const {config} = require('./index')
2
2
 
3
- const plainCssPackages = config.plainCssPackages || []
3
+ const cssInAppStyles = config.cssInAppStyles || []
4
4
 
5
5
  exports.plainCssSplitChunks = () => {
6
- if (!plainCssPackages.length) return {}
7
-
8
- const testRegex = new RegExp(
9
- `[\\\\/]node_modules[\\\\/](${plainCssPackages.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')})[\\\\/]`
10
- )
6
+ if (!cssInAppStyles.length) return {}
11
7
 
12
8
  return {
13
- splitChunks: {
14
- cacheGroups: {
15
- plainCssInEntry: {
16
- type: 'css/mini-extract',
17
- test: testRegex,
18
- name: 'AppStyles',
19
- chunks: 'all',
20
- enforce: true
9
+ plugins: [
10
+ {
11
+ apply(compiler) {
12
+ const pkgPattern = cssInAppStyles.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')
13
+ const pkgRegex = new RegExp(`[\\\\/]node_modules[\\\\/](${pkgPattern})[\\\\/]`)
14
+
15
+ compiler.hooks.thisCompilation.tap('CssInAppStyles', compilation => {
16
+ compilation.hooks.afterOptimizeChunks.tap('CssInAppStyles', chunks => {
17
+ let appStylesChunk = null
18
+ for (const chunk of chunks) {
19
+ if (chunk.name === 'AppStyles') {
20
+ appStylesChunk = chunk
21
+ break
22
+ }
23
+ }
24
+ if (!appStylesChunk) return
25
+
26
+ for (const chunk of chunks) {
27
+ if (chunk === appStylesChunk) continue
28
+ const modulesToMove = []
29
+ for (const module of compilation.chunkGraph.getChunkModulesIterable(chunk)) {
30
+ if (module.type !== 'css/mini-extract') continue
31
+ const name = module.nameForCondition && module.nameForCondition()
32
+ if (name && pkgRegex.test(name)) {
33
+ modulesToMove.push(module)
34
+ }
35
+ }
36
+ for (const module of modulesToMove) {
37
+ compilation.chunkGraph.disconnectChunkAndModule(chunk, module)
38
+ if (!compilation.chunkGraph.isModuleInChunk(module, appStylesChunk)) {
39
+ compilation.chunkGraph.connectChunkAndModule(appStylesChunk, module)
40
+ }
41
+ }
42
+ }
43
+ })
44
+ })
21
45
  }
22
46
  }
23
- }
47
+ ]
24
48
  }
25
49
  }
@@ -66,8 +66,7 @@ const webpackConfig = {
66
66
  checkWasmTypes: false,
67
67
  minimize: true,
68
68
  minimizer: [minifyJs({extractComments, sourceMap}), minifyCss()].filter(Boolean),
69
- runtimeChunk: true,
70
- ...plainCssSplitChunks()
69
+ runtimeChunk: true
71
70
  },
72
71
  cache: {
73
72
  type: 'filesystem',
@@ -75,6 +74,7 @@ const webpackConfig = {
75
74
  compression: false
76
75
  },
77
76
  plugins: cleanList([
77
+ ...plainCssSplitChunks().plugins || [],
78
78
  new webpack.ProvidePlugin({
79
79
  process: 'process/browser.js'
80
80
  }),