@s-ui/bundler 7.33.0-beta.1 → 7.36.0-beta.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/factories/createDevServerConfig.js +0 -1
- package/package.json +15 -15
- package/shared/inline-chunk-html-plugin.js +64 -0
- package/utils/checkRequiredFiles.js +12 -3
- package/utils/clearConsole.js +1 -3
- package/utils/formatWebpackMessages.js +4 -6
- package/webpack.config.dev.js +5 -0
- package/webpack.config.prod.js +7 -6
- package/shared/optimization-split-chunks.js +0 -31
|
@@ -29,7 +29,6 @@ module.exports = config => ({
|
|
|
29
29
|
historyApiFallback: {
|
|
30
30
|
disableDotRule: true
|
|
31
31
|
},
|
|
32
|
-
open: true,
|
|
33
32
|
onAfterSetupMiddleware(devServer) {
|
|
34
33
|
// This service worker file is effectively a 'no-op' that will reset any
|
|
35
34
|
// previous service worker registered for the same host:port combination.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s-ui/bundler",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.36.0-beta.0",
|
|
4
4
|
"description": "Config-free bundler for ES6 React apps.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sui-bundler": "./bin/sui-bundler.js"
|
|
@@ -21,31 +21,31 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-bundler#readme",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@babel/core": "7.
|
|
24
|
+
"@babel/core": "7.16.0",
|
|
25
25
|
"@s-ui/helpers": "1",
|
|
26
|
-
"autoprefixer": "
|
|
26
|
+
"autoprefixer": "10.4.0",
|
|
27
27
|
"babel-loader": "8.2.3",
|
|
28
28
|
"babel-preset-sui": "3",
|
|
29
29
|
"commander": "6.2.1",
|
|
30
|
-
"css-loader": "
|
|
31
|
-
"css-minimizer-webpack-plugin": "1.1
|
|
30
|
+
"css-loader": "6.5.0",
|
|
31
|
+
"css-minimizer-webpack-plugin": "3.1.1",
|
|
32
32
|
"esbuild-loader": "2.16.0",
|
|
33
33
|
"fast-glob": "3.2.7",
|
|
34
|
-
"html-webpack-plugin": "
|
|
35
|
-
"mini-css-extract-plugin": "
|
|
34
|
+
"html-webpack-plugin": "5.5.0",
|
|
35
|
+
"mini-css-extract-plugin": "2.4.3",
|
|
36
36
|
"null-loader": "4.0.1",
|
|
37
|
-
"postcss": "
|
|
38
|
-
"postcss-loader": "
|
|
37
|
+
"postcss": "8.3.11",
|
|
38
|
+
"postcss-loader": "6.2.0",
|
|
39
39
|
"react-dev-utils": "11.0.4",
|
|
40
40
|
"rimraf": "3.0.2",
|
|
41
|
-
"sass": "1.43.
|
|
42
|
-
"sass-loader": "
|
|
41
|
+
"sass": "1.43.4",
|
|
42
|
+
"sass-loader": "12.3.0",
|
|
43
43
|
"super-sass-loader": "0.1",
|
|
44
44
|
"speed-measure-webpack-plugin": "1.5.0",
|
|
45
|
-
"style-loader": "
|
|
46
|
-
"terser-webpack-plugin": "
|
|
47
|
-
"webpack": "
|
|
48
|
-
"webpack-dev-server": "4.
|
|
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",
|
|
49
49
|
"webpack-manifest-plugin": "4.0.2",
|
|
50
50
|
"webpack-node-externals": "3.0.0"
|
|
51
51
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/LICENSE
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
const fs = require('fs')
|
|
2
9
|
const path = require('path')
|
|
3
10
|
|
|
@@ -12,9 +19,11 @@ function checkRequiredFiles(files) {
|
|
|
12
19
|
} catch (err) {
|
|
13
20
|
const dirName = path.dirname(currentFilePath)
|
|
14
21
|
const fileName = path.basename(currentFilePath)
|
|
15
|
-
|
|
16
|
-
console.log('
|
|
17
|
-
console.log(
|
|
22
|
+
|
|
23
|
+
console.log('Could not find a required file:')
|
|
24
|
+
console.log(` Name: ${fileName}`)
|
|
25
|
+
console.log(` Searched in: ${dirName}`)
|
|
26
|
+
|
|
18
27
|
return false
|
|
19
28
|
}
|
|
20
29
|
}
|
package/utils/clearConsole.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in
|
|
5
|
+
* LICENSE file in https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/LICENSE
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
'use strict'
|
|
9
|
-
|
|
10
8
|
function clearConsole() {
|
|
11
9
|
process.stdout.write(
|
|
12
10
|
process.platform === 'win32' ? '\x1B[2J\x1B[0f' : '\x1B[2J\x1B[3J\x1B[H'
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in
|
|
5
|
+
* LICENSE file in https://github.com/facebook/create-react-app/blob/main/packages/react-dev-utils/LICENSE
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
'use strict'
|
|
9
|
-
|
|
10
8
|
const friendlySyntaxErrorLabel = 'Syntax error:'
|
|
11
9
|
|
|
12
10
|
function isLikelyASyntaxError(message) {
|
|
13
|
-
return message.
|
|
11
|
+
return message.includes(friendlySyntaxErrorLabel)
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
// Cleans up webpack error messages.
|
|
@@ -20,11 +18,11 @@ function formatMessage(message) {
|
|
|
20
18
|
if (typeof message === 'string') {
|
|
21
19
|
lines = message.split('\n')
|
|
22
20
|
} else if ('message' in message) {
|
|
23
|
-
lines = message
|
|
21
|
+
lines = message.message.split('\n')
|
|
24
22
|
} else if (Array.isArray(message)) {
|
|
25
23
|
message.forEach(message => {
|
|
26
24
|
if ('message' in message) {
|
|
27
|
-
lines = message
|
|
25
|
+
lines = message.message.split('\n')
|
|
28
26
|
}
|
|
29
27
|
})
|
|
30
28
|
}
|
package/webpack.config.dev.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
const path = require('path')
|
|
2
4
|
const webpack = require('webpack')
|
|
3
5
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
@@ -16,6 +18,9 @@ const useExperimentalSCSSLoader =
|
|
|
16
18
|
|
|
17
19
|
const smp = new SpeedMeasurePlugin()
|
|
18
20
|
|
|
21
|
+
/** @typedef {import('webpack').Configuration} WebpackConfig */
|
|
22
|
+
|
|
23
|
+
/** @type {WebpackConfig} */
|
|
19
24
|
const webpackConfig = {
|
|
20
25
|
mode: 'development',
|
|
21
26
|
context: path.resolve(process.env.PWD, 'src'),
|
package/webpack.config.prod.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
1
3
|
/* eslint-disable no-console */
|
|
2
4
|
const webpack = require('webpack')
|
|
3
5
|
const path = require('path')
|
|
@@ -5,7 +7,7 @@ const path = require('path')
|
|
|
5
7
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
6
8
|
const {WebpackManifestPlugin} = require('webpack-manifest-plugin')
|
|
7
9
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
8
|
-
const InlineChunkHtmlPlugin = require('
|
|
10
|
+
const InlineChunkHtmlPlugin = require('./shared/inline-chunk-html-plugin.js')
|
|
9
11
|
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
|
|
10
12
|
const {
|
|
11
13
|
when,
|
|
@@ -19,7 +21,6 @@ const minifyCss = require('./shared/minify-css')
|
|
|
19
21
|
const definePlugin = require('./shared/define')
|
|
20
22
|
const babelRules = require('./shared/module-rules-babel')
|
|
21
23
|
const manifestLoaderRules = require('./shared/module-rules-manifest-loader')
|
|
22
|
-
const {splitChunks} = require('./shared/optimization-split-chunks')
|
|
23
24
|
const {
|
|
24
25
|
extractComments,
|
|
25
26
|
useExperimentalMinifier,
|
|
@@ -40,6 +41,9 @@ const cssFileName = config.onlyHash
|
|
|
40
41
|
|
|
41
42
|
const smp = new SpeedMeasurePlugin()
|
|
42
43
|
|
|
44
|
+
/** @typedef {import('webpack').Configuration} WebpackConfig */
|
|
45
|
+
|
|
46
|
+
/** @type {WebpackConfig} */
|
|
43
47
|
const webpackConfig = {
|
|
44
48
|
devtool: sourceMap,
|
|
45
49
|
mode: 'production',
|
|
@@ -63,15 +67,12 @@ const webpackConfig = {
|
|
|
63
67
|
publicPath: PUBLIC_PATH
|
|
64
68
|
},
|
|
65
69
|
optimization: {
|
|
66
|
-
// avoid looping over all the modules after the compilation
|
|
67
|
-
checkWasmTypes: false,
|
|
68
70
|
minimize: true,
|
|
69
71
|
minimizer: [
|
|
70
72
|
minifyJs({useExperimentalMinifier, extractComments, sourceMap}),
|
|
71
73
|
minifyCss()
|
|
72
74
|
].filter(Boolean),
|
|
73
|
-
runtimeChunk: true
|
|
74
|
-
splitChunks
|
|
75
|
+
runtimeChunk: true
|
|
75
76
|
},
|
|
76
77
|
plugins: cleanList([
|
|
77
78
|
new webpack.HashedModuleIdsPlugin(),
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|