@s-ui/bundler 7.36.0-beta.0 → 7.38.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # sui-bunder
1
+ # sui-bundler
2
2
 
3
3
  > Config-free bundler for ES6 React apps.
4
4
 
@@ -25,7 +25,8 @@ const linkLoaderConfigBuilder = require('../loaders/linkLoaderConfigBuilder')
25
25
  const log = require('../shared/log')
26
26
 
27
27
  const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000
28
- const HOST = process.env.HOST || '0.0.0.0'
28
+ const {CI = false, HOST = '0.0.0.0'} = process.env
29
+ const DEFAULT_WATCH = !CI
29
30
 
30
31
  if (!module.parent) {
31
32
  program
@@ -43,6 +44,11 @@ if (!module.parent) {
43
44
  },
44
45
  []
45
46
  )
47
+ .option(
48
+ '-w, --watch',
49
+ 'Watch files and restart the server on change',
50
+ DEFAULT_WATCH
51
+ )
46
52
  .on('--help', () => {
47
53
  console.log(' Examples:')
48
54
  console.log('')
@@ -52,6 +58,7 @@ if (!module.parent) {
52
58
  console.log('')
53
59
  })
54
60
  .parse(process.argv)
61
+
55
62
  const {context} = program
56
63
  webpackConfig.context = context || webpackConfig.context
57
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@s-ui/bundler",
3
- "version": "7.36.0-beta.0",
3
+ "version": "7.38.0",
4
4
  "description": "Config-free bundler for ES6 React apps.",
5
5
  "bin": {
6
6
  "sui-bundler": "./bin/sui-bundler.js"
@@ -23,29 +23,29 @@
23
23
  "dependencies": {
24
24
  "@babel/core": "7.16.0",
25
25
  "@s-ui/helpers": "1",
26
- "autoprefixer": "10.4.0",
26
+ "autoprefixer": "9.8.6",
27
27
  "babel-loader": "8.2.3",
28
28
  "babel-preset-sui": "3",
29
29
  "commander": "6.2.1",
30
- "css-loader": "6.5.0",
31
- "css-minimizer-webpack-plugin": "3.1.1",
30
+ "css-loader": "4.3.0",
31
+ "css-minimizer-webpack-plugin": "1.1.5",
32
32
  "esbuild-loader": "2.16.0",
33
33
  "fast-glob": "3.2.7",
34
- "html-webpack-plugin": "5.5.0",
35
- "mini-css-extract-plugin": "2.4.3",
34
+ "html-webpack-plugin": "4.5.0",
35
+ "mini-css-extract-plugin": "1.6.0",
36
36
  "null-loader": "4.0.1",
37
- "postcss": "8.3.11",
38
- "postcss-loader": "6.2.0",
37
+ "postcss": "7.0.35",
38
+ "postcss-loader": "4.1.0",
39
39
  "react-dev-utils": "11.0.4",
40
40
  "rimraf": "3.0.2",
41
- "sass": "1.43.4",
42
- "sass-loader": "12.3.0",
41
+ "sass": "1.43.3",
42
+ "sass-loader": "10.1.0",
43
43
  "super-sass-loader": "0.1",
44
44
  "speed-measure-webpack-plugin": "1.5.0",
45
- "style-loader": "3.3.1",
46
- "terser-webpack-plugin": "5.2.4",
47
- "webpack": "5.61.0",
48
- "webpack-dev-server": "4.4.0",
45
+ "style-loader": "2.0.0",
46
+ "terser-webpack-plugin": "4.2.2",
47
+ "webpack": "4.46.0",
48
+ "webpack-dev-server": "4.3.1",
49
49
  "webpack-manifest-plugin": "4.0.2",
50
50
  "webpack-node-externals": "3.0.0"
51
51
  }
@@ -0,0 +1,31 @@
1
+ const {config} = require('./')
2
+
3
+ const hasToSplitFrameworksOnChunk =
4
+ config.optimizations && config.optimizations.splitFrameworkOnChunk
5
+
6
+ const frameworkSplitChunk = {
7
+ framework: {
8
+ chunks: 'all',
9
+ name: 'framework',
10
+ // This regex ignores nested copies of framework libraries so they're
11
+ // bundled with their issuer: https://github.com/vercel/next.js/pull/9012
12
+ test: /(?<!node_modules.*)[\\/]node_modules[\\/](react|react-dom|scheduler|prop-types|use-subscription)[\\/]/,
13
+ priority: 40,
14
+ // Don't let webpack eliminate this chunk (prevents this chunk from
15
+ // becoming a part of the commons chunk)
16
+ enforce: true
17
+ }
18
+ }
19
+
20
+ exports.splitChunks = {
21
+ cacheGroups: {
22
+ ...(hasToSplitFrameworksOnChunk && frameworkSplitChunk),
23
+ vendor: {
24
+ chunks: 'all',
25
+ name: 'vendor',
26
+ test: 'vendor',
27
+ enforce: true,
28
+ reuseExistingChunk: true
29
+ }
30
+ }
31
+ }
@@ -1,5 +1,3 @@
1
- // @ts-check
2
-
3
1
  const path = require('path')
4
2
  const webpack = require('webpack')
5
3
  const HtmlWebpackPlugin = require('html-webpack-plugin')
@@ -18,9 +16,6 @@ const useExperimentalSCSSLoader =
18
16
 
19
17
  const smp = new SpeedMeasurePlugin()
20
18
 
21
- /** @typedef {import('webpack').Configuration} WebpackConfig */
22
-
23
- /** @type {WebpackConfig} */
24
19
  const webpackConfig = {
25
20
  mode: 'development',
26
21
  context: path.resolve(process.env.PWD, 'src'),
@@ -1,5 +1,3 @@
1
- // @ts-check
2
-
3
1
  /* eslint-disable no-console */
4
2
  const webpack = require('webpack')
5
3
  const path = require('path')
@@ -7,7 +5,7 @@ const path = require('path')
7
5
  const HtmlWebpackPlugin = require('html-webpack-plugin')
8
6
  const {WebpackManifestPlugin} = require('webpack-manifest-plugin')
9
7
  const MiniCssExtractPlugin = require('mini-css-extract-plugin')
10
- const InlineChunkHtmlPlugin = require('./shared/inline-chunk-html-plugin.js')
8
+ const InlineChunkHtmlPlugin = require('react-dev-utils/InlineChunkHtmlPlugin')
11
9
  const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
12
10
  const {
13
11
  when,
@@ -21,6 +19,7 @@ const minifyCss = require('./shared/minify-css')
21
19
  const definePlugin = require('./shared/define')
22
20
  const babelRules = require('./shared/module-rules-babel')
23
21
  const manifestLoaderRules = require('./shared/module-rules-manifest-loader')
22
+ const {splitChunks} = require('./shared/optimization-split-chunks')
24
23
  const {
25
24
  extractComments,
26
25
  useExperimentalMinifier,
@@ -41,9 +40,6 @@ const cssFileName = config.onlyHash
41
40
 
42
41
  const smp = new SpeedMeasurePlugin()
43
42
 
44
- /** @typedef {import('webpack').Configuration} WebpackConfig */
45
-
46
- /** @type {WebpackConfig} */
47
43
  const webpackConfig = {
48
44
  devtool: sourceMap,
49
45
  mode: 'production',
@@ -67,12 +63,15 @@ const webpackConfig = {
67
63
  publicPath: PUBLIC_PATH
68
64
  },
69
65
  optimization: {
66
+ // avoid looping over all the modules after the compilation
67
+ checkWasmTypes: false,
70
68
  minimize: true,
71
69
  minimizer: [
72
70
  minifyJs({useExperimentalMinifier, extractComments, sourceMap}),
73
71
  minifyCss()
74
72
  ].filter(Boolean),
75
- runtimeChunk: true
73
+ runtimeChunk: true,
74
+ splitChunks
76
75
  },
77
76
  plugins: cleanList([
78
77
  new webpack.HashedModuleIdsPlugin(),
@@ -1,64 +0,0 @@
1
- // from: https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/InlineChunkHtmlPlugin.js
2
-
3
- /**
4
- * Copyright (c) 2015-present, Facebook, Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
-
10
- 'use strict'
11
-
12
- class InlineChunkHtmlPlugin {
13
- constructor(htmlWebpackPlugin, tests) {
14
- this.htmlWebpackPlugin = htmlWebpackPlugin
15
- this.tests = tests
16
- }
17
-
18
- getInlinedTag(publicPath, assets, tag) {
19
- if (tag.tagName !== 'script' || !(tag.attributes && tag.attributes.src)) {
20
- return tag
21
- }
22
- const scriptName = publicPath
23
- ? tag.attributes.src.replace(publicPath, '')
24
- : tag.attributes.src
25
- if (!this.tests.some(test => scriptName.match(test))) {
26
- return tag
27
- }
28
- const asset = assets[scriptName]
29
- if (asset == null) {
30
- return tag
31
- }
32
- return {tagName: 'script', innerHTML: asset.source(), closeTag: true}
33
- }
34
-
35
- apply(compiler) {
36
- let publicPath = compiler.options.output.publicPath || ''
37
- if (publicPath && !publicPath.endsWith('/')) {
38
- publicPath += '/'
39
- }
40
-
41
- compiler.hooks.compilation.tap('InlineChunkHtmlPlugin', compilation => {
42
- const tagFunction = tag =>
43
- this.getInlinedTag(publicPath, compilation.assets, tag)
44
-
45
- const hooks = this.htmlWebpackPlugin.getHooks(compilation)
46
- hooks.alterAssetTagGroups.tap('InlineChunkHtmlPlugin', assets => {
47
- assets.headTags = assets.headTags.map(tagFunction)
48
- assets.bodyTags = assets.bodyTags.map(tagFunction)
49
- })
50
-
51
- // Still emit the runtime chunk for users who do not use our generated
52
- // index.html file.
53
- // hooks.afterEmit.tap('InlineChunkHtmlPlugin', () => {
54
- // Object.keys(compilation.assets).forEach(assetName => {
55
- // if (this.tests.some(test => assetName.match(test))) {
56
- // delete compilation.assets[assetName];
57
- // }
58
- // });
59
- // });
60
- })
61
- }
62
- }
63
-
64
- module.exports = InlineChunkHtmlPlugin