@s-ui/bundler 9.31.0 → 9.34.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/bin/sui-bundler-build.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// @ts-check
|
|
4
|
+
|
|
2
5
|
/* eslint-disable no-console */
|
|
3
6
|
|
|
4
7
|
const fs = require('fs')
|
|
@@ -63,21 +66,24 @@ if (clean) {
|
|
|
63
66
|
|
|
64
67
|
log.processing('Generating minified bundle...')
|
|
65
68
|
|
|
66
|
-
webpack(nextConfig)
|
|
69
|
+
const compiler = webpack(nextConfig)
|
|
70
|
+
|
|
71
|
+
compiler.run(async (error, stats) => {
|
|
67
72
|
if (error) {
|
|
68
73
|
log.error(error)
|
|
69
|
-
return 1
|
|
74
|
+
return process.exit(1)
|
|
70
75
|
}
|
|
71
76
|
|
|
72
|
-
if (stats
|
|
77
|
+
if (stats?.hasErrors()) {
|
|
73
78
|
const jsonStats = stats.toJson('errors-only')
|
|
74
|
-
|
|
79
|
+
jsonStats?.errors?.map(({message}) => log.error(message))
|
|
80
|
+
return process.exit(1)
|
|
75
81
|
}
|
|
76
82
|
|
|
77
|
-
if (stats
|
|
83
|
+
if (stats?.hasWarnings()) {
|
|
78
84
|
const jsonStats = stats.toJson('errors-warnings')
|
|
79
85
|
log.warn('Webpack generated the following warnings: ')
|
|
80
|
-
jsonStats
|
|
86
|
+
jsonStats?.warnings?.map(({message}) => log.warn(message))
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
console.log(`Webpack stats: ${stats}`)
|
|
@@ -147,5 +153,9 @@ webpack(nextConfig).run(async (error, stats) => {
|
|
|
147
153
|
`Your app is compiled in ${process.env.NODE_ENV} mode in /public. It's ready to roll!`
|
|
148
154
|
)
|
|
149
155
|
|
|
150
|
-
|
|
156
|
+
compiler.close(closeErr => {
|
|
157
|
+
const exitCode = closeErr ? 1 : 0
|
|
158
|
+
if (closeErr) return process.exit(exitCode)
|
|
159
|
+
return process.exit(0)
|
|
160
|
+
})
|
|
151
161
|
})
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const path = require('path')
|
|
2
2
|
const {config} = require('./index.js')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const EXCLUDED_FOLDERS_REGEXP = new RegExp(
|
|
5
|
+
`node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)`
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
module.exports = ({isServer = false} = {}) => ({
|
|
5
9
|
test: /\.jsx?$/,
|
|
6
|
-
exclude:
|
|
10
|
+
exclude: EXCLUDED_FOLDERS_REGEXP,
|
|
7
11
|
use: [
|
|
8
12
|
{
|
|
9
13
|
loader: require.resolve('babel-loader'),
|
|
@@ -16,6 +20,8 @@ module.exports = {
|
|
|
16
20
|
[
|
|
17
21
|
require.resolve('babel-preset-sui'),
|
|
18
22
|
{
|
|
23
|
+
isServer,
|
|
24
|
+
supportLegacyBrowsers: true,
|
|
19
25
|
targets: config.targets
|
|
20
26
|
}
|
|
21
27
|
]
|
|
@@ -23,4 +29,4 @@ module.exports = {
|
|
|
23
29
|
}
|
|
24
30
|
}
|
|
25
31
|
]
|
|
26
|
-
}
|
|
32
|
+
})
|
package/webpack.config.dev.js
CHANGED
|
@@ -16,13 +16,11 @@ const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
|
|
|
16
16
|
const {aliasFromConfig, defaultAlias} = require('./shared/resolve-alias.js')
|
|
17
17
|
|
|
18
18
|
const {resolveLoader} = require('./shared/resolve-loader.js')
|
|
19
|
+
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
19
20
|
|
|
20
|
-
const EXCLUDED_FOLDERS_REGEXP = new RegExp(
|
|
21
|
-
`node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)`
|
|
22
|
-
)
|
|
23
21
|
const outputPath = path.join(process.cwd(), 'dist')
|
|
24
22
|
|
|
25
|
-
const {CI = false} = process.env
|
|
23
|
+
const {CI = false, PWD = ''} = process.env
|
|
26
24
|
|
|
27
25
|
process.env.NODE_ENV = 'development'
|
|
28
26
|
|
|
@@ -31,7 +29,7 @@ process.env.NODE_ENV = 'development'
|
|
|
31
29
|
/** @type {WebpackConfig} */
|
|
32
30
|
const webpackConfig = {
|
|
33
31
|
mode: 'development',
|
|
34
|
-
context: path.resolve(
|
|
32
|
+
context: path.resolve(PWD, 'src'),
|
|
35
33
|
resolve: {
|
|
36
34
|
alias: {
|
|
37
35
|
...defaultAlias,
|
|
@@ -81,20 +79,7 @@ const webpackConfig = {
|
|
|
81
79
|
resolveLoader,
|
|
82
80
|
module: {
|
|
83
81
|
rules: cleanList([
|
|
84
|
-
|
|
85
|
-
test: /\.jsx?$/,
|
|
86
|
-
exclude: EXCLUDED_FOLDERS_REGEXP,
|
|
87
|
-
use: [
|
|
88
|
-
{
|
|
89
|
-
loader: require.resolve('babel-loader'),
|
|
90
|
-
options: {
|
|
91
|
-
babelrc: false,
|
|
92
|
-
cacheDirectory: true,
|
|
93
|
-
presets: [require.resolve('babel-preset-sui')]
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
},
|
|
82
|
+
createBabelRules(),
|
|
98
83
|
{
|
|
99
84
|
test: /(\.css|\.scss)$/,
|
|
100
85
|
use: cleanList([
|
package/webpack.config.lib.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
const path = require('path')
|
|
10
10
|
const minifyJs = require('./shared/minify-js.js')
|
|
11
11
|
const definePlugin = require('./shared/define.js')
|
|
12
|
-
const
|
|
12
|
+
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
13
13
|
const sassRules = require('./shared/module-rules-sass.js')
|
|
14
14
|
const {extractComments, sourceMap} = require('./shared/config.js')
|
|
15
15
|
const {aliasFromConfig} = require('./shared/resolve-alias.js')
|
|
@@ -63,6 +63,6 @@ module.exports = {
|
|
|
63
63
|
definePlugin()
|
|
64
64
|
]),
|
|
65
65
|
module: {
|
|
66
|
-
rules: [
|
|
66
|
+
rules: [createBabelRules(), sassRules]
|
|
67
67
|
}
|
|
68
68
|
}
|
package/webpack.config.prod.js
CHANGED
|
@@ -23,14 +23,16 @@ const {
|
|
|
23
23
|
supportLegacyBrowsers
|
|
24
24
|
} = require('./shared/config.js')
|
|
25
25
|
const {resolveLoader} = require('./shared/resolve-loader.js')
|
|
26
|
-
const
|
|
26
|
+
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
27
27
|
const sassRules = require('./shared/module-rules-sass.js')
|
|
28
28
|
const definePlugin = require('./shared/define.js')
|
|
29
29
|
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
|
|
30
30
|
const minifyCss = require('./shared/minify-css.js')
|
|
31
31
|
const minifyJs = require('./shared/minify-js.js')
|
|
32
32
|
|
|
33
|
+
const CWD = process.cwd()
|
|
33
34
|
const PUBLIC_PATH = process.env.CDN || config.cdn || '/'
|
|
35
|
+
const PWD = process.env.PWD ?? ''
|
|
34
36
|
|
|
35
37
|
const filename = config.onlyHash
|
|
36
38
|
? '[contenthash:8].js'
|
|
@@ -49,11 +51,11 @@ const webpackConfig = {
|
|
|
49
51
|
devtool: sourceMap,
|
|
50
52
|
mode: 'production',
|
|
51
53
|
target,
|
|
52
|
-
context: path.resolve(
|
|
54
|
+
context: path.resolve(CWD, 'src'),
|
|
53
55
|
resolve: {
|
|
54
56
|
alias: {...aliasFromConfig},
|
|
55
57
|
extensions: ['.js', '.json'],
|
|
56
|
-
modules: ['node_modules', path.resolve(
|
|
58
|
+
modules: ['node_modules', path.resolve(CWD)],
|
|
57
59
|
fallback: {
|
|
58
60
|
assert: false,
|
|
59
61
|
fs: false,
|
|
@@ -66,7 +68,7 @@ const webpackConfig = {
|
|
|
66
68
|
output: {
|
|
67
69
|
chunkFilename: filename,
|
|
68
70
|
filename,
|
|
69
|
-
path: path.resolve(
|
|
71
|
+
path: path.resolve(PWD, 'public'),
|
|
70
72
|
publicPath: PUBLIC_PATH
|
|
71
73
|
},
|
|
72
74
|
optimization: {
|
|
@@ -109,7 +111,7 @@ const webpackConfig = {
|
|
|
109
111
|
]),
|
|
110
112
|
module: {
|
|
111
113
|
rules: cleanList([
|
|
112
|
-
|
|
114
|
+
createBabelRules(),
|
|
113
115
|
sassRules,
|
|
114
116
|
when(config['externals-manifest'], () =>
|
|
115
117
|
manifestLoaderRules(config['externals-manifest'])
|
package/webpack.config.server.js
CHANGED
|
@@ -3,7 +3,7 @@ const webpackNodeExternals = require('webpack-node-externals')
|
|
|
3
3
|
const path = require('path')
|
|
4
4
|
|
|
5
5
|
const {config, when, cleanList} = require('./shared/index.js')
|
|
6
|
-
const
|
|
6
|
+
const createBabelRules = require('./shared/module-rules-babel.js')
|
|
7
7
|
const manifestLoaderRules = require('./shared/module-rules-manifest-loader.js')
|
|
8
8
|
const {aliasFromConfig} = require('./shared/resolve-alias.js')
|
|
9
9
|
const {resolveLoader} = require('./shared/resolve-loader.js')
|
|
@@ -39,7 +39,7 @@ const webpackConfig = {
|
|
|
39
39
|
resolveLoader,
|
|
40
40
|
module: {
|
|
41
41
|
rules: cleanList([
|
|
42
|
-
|
|
42
|
+
createBabelRules({isServer: true}),
|
|
43
43
|
{
|
|
44
44
|
// ignore css/scss/svg require/imports files in the server
|
|
45
45
|
test: /(\.svg|\.s?css)$/,
|