@s-ui/bundler 8.0.0-beta.0 → 8.0.0-beta.4
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 +36 -15
- package/bin/sui-bundler-analyzer.js +9 -3
- package/bin/sui-bundler-build.js +1 -1
- package/bin/sui-bundler-dev.js +77 -33
- package/factories/createCompiler.js +23 -7
- package/factories/createDevServerConfig.js +43 -0
- package/loaders/linkLoaderConfigBuilder.js +2 -2
- package/package.json +23 -23
- package/shared/config.js +1 -1
- package/{plugins/InlineChunkHtmlPlugin.js → shared/inline-chunk-html-plugin.js} +2 -0
- package/shared/log.js +6 -7
- package/shared/minify-css.js +3 -1
- package/shared/minify-js.js +8 -45
- package/shared/module-rules-babel.js +2 -0
- package/shared/resolve-alias.js +1 -0
- package/utils/checkRequiredFiles.js +31 -0
- package/utils/clearConsole.js +14 -0
- package/utils/formatWebpackMessages.js +126 -0
- package/webpack.config.dev.js +19 -19
- package/webpack.config.lib.js +3 -1
- package/webpack.config.prod.js +19 -15
- package/webpack.config.server.js +11 -4
- package/CHANGELOG.md +0 -1463
- package/shared/optimization-split-chunks.js +0 -31
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# sui-
|
|
1
|
+
# sui-bundler
|
|
2
2
|
|
|
3
3
|
> Config-free bundler for ES6 React apps.
|
|
4
4
|
|
|
@@ -81,6 +81,12 @@ To link more than one package at time, use as many times as desired the argument
|
|
|
81
81
|
$ sui-bundler dev --link-package=/absolute_path/to/npm_package --link-package=/absolute_path2/to/npm_package
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
You can also use `-l` as a shorthand to link a package.
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
$ sui-bundler dev -l /absolute_path/to/npm_package -l /absolute_path2/to/npm_package
|
|
88
|
+
```
|
|
89
|
+
|
|
84
90
|
If you want to link all the packages inside a monorepo-multipackage. Use the flag `--link-all` pointing to the folder where each package lives.
|
|
85
91
|
For example, if you want to link all the components in a Studio, the command should be:
|
|
86
92
|
|
|
@@ -88,6 +94,12 @@ For example, if you want to link all the components in a Studio, the command sho
|
|
|
88
94
|
$ sui-bundler dev --link-all ../frontend-ma--uilib-components/components
|
|
89
95
|
```
|
|
90
96
|
|
|
97
|
+
You can use `-L` as a shorthand to link all packages.
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
$ sui-bundler dev -L ../frontend-ma--uilib-components/components
|
|
101
|
+
```
|
|
102
|
+
|
|
91
103
|
And of course you can combine `link-all` and `link-package` flags
|
|
92
104
|
|
|
93
105
|
### Production
|
|
@@ -124,6 +136,7 @@ sui-bundler lib umd/index.js -o lib/fancy -p http://my-cdn.com/fancy
|
|
|
124
136
|
```
|
|
125
137
|
|
|
126
138
|
`sui-bundler lib` will add your package version as subfolder:
|
|
139
|
+
|
|
127
140
|
- `-o lib/fancy` outputs to `./lib/fancy/0.0.0/`
|
|
128
141
|
- `-p http://my-cdn.com/fancy` sets `http://my-cdn.com/fancy/0.0.0` as public path for chunks loading.
|
|
129
142
|
- `-r http://my-cdn.com/fancy` sets `http://my-cdn.com/fancy` as public path for chunks loading, discarded the version subdirectory.
|
|
@@ -155,7 +168,10 @@ This tool works with zero configuration out the box but you could use some confi
|
|
|
155
168
|
"vendor": ["react", "react-dom"],
|
|
156
169
|
"cdn": "https://url_to_me_cdn.com/",
|
|
157
170
|
"externals-manifest": "https://url_to_me_cdn/manifest.json",
|
|
158
|
-
"alias": {
|
|
171
|
+
"alias": {
|
|
172
|
+
"react": "preact"
|
|
173
|
+
},
|
|
174
|
+
"measure": true,
|
|
159
175
|
"offline": true,
|
|
160
176
|
"targets": {
|
|
161
177
|
"chrome": "41",
|
|
@@ -167,9 +183,6 @@ This tool works with zero configuration out the box but you could use some confi
|
|
|
167
183
|
"sourcemaps": {
|
|
168
184
|
"dev": "cheap-module-eval-source-map",
|
|
169
185
|
"prod": "hidden-source-map"
|
|
170
|
-
},
|
|
171
|
-
"optimizations": {
|
|
172
|
-
"splitFrameworkOnChunk": true
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
188
|
}
|
|
@@ -193,20 +206,24 @@ import {register, unregister} from '@s-ui/bundler/registerServiceWorker'
|
|
|
193
206
|
register({
|
|
194
207
|
first: () => window.alert('Content is cached for offline use.'),
|
|
195
208
|
renovate: () => window.alert('New content is available; please refresh.')
|
|
196
|
-
})
|
|
209
|
+
})
|
|
197
210
|
```
|
|
198
211
|
|
|
199
212
|
You should pass a handler in order to handle when content gets cached for the first time the content and another when you get new content and want to handle how to show a notification to the user in order to let him decide if he wants to refresh the page.
|
|
200
213
|
|
|
201
214
|
If you want to remove your ServiceWorker, you need to use the method `unregister`, the same way you used the `register` method before.
|
|
202
215
|
|
|
216
|
+
### Build time measurement
|
|
217
|
+
|
|
218
|
+
Set `measure` to `true` if you want to check step by step build times.
|
|
219
|
+
|
|
203
220
|
### Only Caching
|
|
204
221
|
|
|
205
222
|
It's possible to create a service worker that caches all static resources
|
|
206
223
|
|
|
207
224
|
There are two ways to activate the statics cache option:
|
|
208
225
|
|
|
209
|
-
1. Create a `src/offline.html` page as mentioned in the [offline](
|
|
226
|
+
1. Create a `src/offline.html` page as mentioned in the [offline](#Offline) section
|
|
210
227
|
2. Add the `staticsCacheOnly` option within the package.json like this:
|
|
211
228
|
|
|
212
229
|
```json
|
|
@@ -218,9 +235,11 @@ There are two ways to activate the statics cache option:
|
|
|
218
235
|
}
|
|
219
236
|
}
|
|
220
237
|
```
|
|
238
|
+
|
|
221
239
|
> Statics will be cached but no offline page will be activated
|
|
222
240
|
|
|
223
241
|
## Externals Manifest
|
|
242
|
+
|
|
224
243
|
If your are using an external CDN to store statics assets that are now managed by Webpack, like SVG or IMGs, you can create a manifest.json file in the root of your CDN (likehttps://spa-mock-statics.surge.sh/manifest.json`).
|
|
225
244
|
|
|
226
245
|
If you define the `externals-manifest` key in the config pointing to this link, sui-bundler will replace any ocurrence of each key for the value
|
|
@@ -230,14 +249,19 @@ If in your CSS you have:
|
|
|
230
249
|
```css
|
|
231
250
|
#app {
|
|
232
251
|
color: blue;
|
|
233
|
-
background: url('https://spa-mock-statics.surge.sh/images/common/sprite-sheet/sprite-ma.png')
|
|
252
|
+
background: url('https://spa-mock-statics.surge.sh/images/common/sprite-sheet/sprite-ma.png')
|
|
253
|
+
no-repeat scroll;
|
|
234
254
|
}
|
|
235
255
|
```
|
|
236
256
|
|
|
237
257
|
After compile you will get:
|
|
238
258
|
|
|
239
259
|
```css
|
|
240
|
-
#app{
|
|
260
|
+
#app {
|
|
261
|
+
color: #00f;
|
|
262
|
+
background: url(https://spa-mock-statics.surge.sh/images/common/sprite-sheet/sprite-ma.72d1edb214.png)
|
|
263
|
+
no-repeat scroll;
|
|
264
|
+
}
|
|
241
265
|
```
|
|
242
266
|
|
|
243
267
|
Or if in your JS you have:
|
|
@@ -284,16 +308,13 @@ Different values can be configured for development (`dev`) and production (`prod
|
|
|
284
308
|
}
|
|
285
309
|
```
|
|
286
310
|
|
|
287
|
-
|
|
288
311
|
Check all possible values accepted by webpack in the [devtool webpack docs](https://webpack.js.org/configuration/devtool/#devtool)
|
|
289
312
|
|
|
290
|
-
##
|
|
291
|
-
|
|
292
|
-
You could tweak the performance of your bundle generation by using some flags provided in this config.
|
|
313
|
+
## Migrations
|
|
293
314
|
|
|
294
|
-
|
|
315
|
+
### Migrate from v7 to v8
|
|
295
316
|
|
|
296
|
-
|
|
317
|
+
`useExperimentalSCSSLoader` is not used anymore and it will be ignored.
|
|
297
318
|
|
|
298
319
|
### Migrate from v6 to v7
|
|
299
320
|
|
|
@@ -10,7 +10,7 @@ const logUpdate = require('@s-ui/helpers/log-update')
|
|
|
10
10
|
const installNeededDependencies = async () => {
|
|
11
11
|
try {
|
|
12
12
|
require('webpack-bundle-analyzer')
|
|
13
|
-
|
|
13
|
+
return true
|
|
14
14
|
} catch (e) {
|
|
15
15
|
logUpdate('Installing needed dependencies...')
|
|
16
16
|
return getSpawnPromise('npm', [
|
|
@@ -19,14 +19,20 @@ const installNeededDependencies = async () => {
|
|
|
19
19
|
'--no-optional',
|
|
20
20
|
'--no-audit',
|
|
21
21
|
'--no-fund',
|
|
22
|
-
'webpack-bundle-analyzer@4.
|
|
22
|
+
'webpack-bundle-analyzer@4.3.0 duplicate-package-checker-webpack-plugin@3.0.0'
|
|
23
23
|
]).then(() => {
|
|
24
24
|
logUpdate.done('Installed needed dependencies')
|
|
25
|
+
getSpawnPromise('./node_modules/.bin/sui-bundler', ['analyzer']).then(
|
|
26
|
+
() => false
|
|
27
|
+
)
|
|
25
28
|
})
|
|
26
29
|
}
|
|
27
30
|
}
|
|
31
|
+
|
|
28
32
|
;(async () => {
|
|
29
|
-
await installNeededDependencies()
|
|
33
|
+
const keepExecution = await installNeededDependencies()
|
|
34
|
+
if (!keepExecution) return
|
|
35
|
+
|
|
30
36
|
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
|
|
31
37
|
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin')
|
|
32
38
|
|
package/bin/sui-bundler-build.js
CHANGED
|
@@ -19,7 +19,7 @@ process.env.NODE_ENV = process.env.NODE_ENV || 'production'
|
|
|
19
19
|
program
|
|
20
20
|
.option('-C, --clean', 'Remove public folder before create a new one')
|
|
21
21
|
.option(
|
|
22
|
-
'--link-package [package]',
|
|
22
|
+
'-l, --link-package [package]',
|
|
23
23
|
'Replace each occurrence of this package with an absolute path to this folder',
|
|
24
24
|
(v, m) => {
|
|
25
25
|
m.push(v)
|
package/bin/sui-bundler-dev.js
CHANGED
|
@@ -1,46 +1,67 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
|
|
4
|
+
process.on('unhandledRejection', err => {
|
|
5
|
+
throw err
|
|
6
|
+
})
|
|
7
|
+
|
|
4
8
|
const program = require('commander')
|
|
5
9
|
const path = require('path')
|
|
6
|
-
const
|
|
7
|
-
|
|
10
|
+
const WebpackDevServer = require('webpack-dev-server')
|
|
11
|
+
|
|
12
|
+
const clearConsole = require('../utils/clearConsole')
|
|
13
|
+
const checkRequiredFiles = require('../utils/checkRequiredFiles')
|
|
14
|
+
const {
|
|
15
|
+
choosePort,
|
|
16
|
+
prepareUrls
|
|
17
|
+
} = require('react-dev-utils/WebpackDevServerUtils')
|
|
8
18
|
|
|
9
19
|
const webpackConfig = require('../webpack.config.dev')
|
|
20
|
+
|
|
21
|
+
const createDevServerConfig = require('../factories/createDevServerConfig')
|
|
10
22
|
const createCompiler = require('../factories/createCompiler')
|
|
11
23
|
|
|
12
24
|
const linkLoaderConfigBuilder = require('../loaders/linkLoaderConfigBuilder')
|
|
13
25
|
const log = require('../shared/log')
|
|
14
26
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
27
|
+
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000
|
|
28
|
+
const {CI = false, HOST = '0.0.0.0'} = process.env
|
|
29
|
+
const DEFAULT_WATCH = !CI
|
|
30
|
+
|
|
31
|
+
if (!module.parent) {
|
|
32
|
+
program
|
|
33
|
+
.option('-c, --context [folder]', 'Context folder (cwd by default)')
|
|
34
|
+
.option(
|
|
35
|
+
'-L, --link-all [monorepo]',
|
|
36
|
+
'Link all packages inside of monorepo multipackage'
|
|
37
|
+
)
|
|
38
|
+
.option(
|
|
39
|
+
'-l, --link-package [package]',
|
|
40
|
+
'Replace each occurrence of this package with an absolute path to this folder',
|
|
41
|
+
(v, m) => {
|
|
42
|
+
m.push(v)
|
|
43
|
+
return m
|
|
44
|
+
},
|
|
45
|
+
[]
|
|
46
|
+
)
|
|
47
|
+
.option(
|
|
48
|
+
'-w, --watch',
|
|
49
|
+
'Watch files and restart the server on change',
|
|
50
|
+
DEFAULT_WATCH
|
|
51
|
+
)
|
|
52
|
+
.on('--help', () => {
|
|
53
|
+
console.log(' Examples:')
|
|
54
|
+
console.log('')
|
|
55
|
+
console.log(' $ sui-bundler dev')
|
|
56
|
+
console.log(' $ sui-bundler dev --context /my/app/folder')
|
|
57
|
+
console.log(' $ sui-bundler dev --link-package /my/domain/folder')
|
|
58
|
+
console.log('')
|
|
59
|
+
})
|
|
60
|
+
.parse(process.argv)
|
|
41
61
|
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
const {context} = program
|
|
63
|
+
webpackConfig.context = context || webpackConfig.context
|
|
64
|
+
}
|
|
44
65
|
|
|
45
66
|
const start = async ({
|
|
46
67
|
config = webpackConfig,
|
|
@@ -59,15 +80,38 @@ const start = async ({
|
|
|
59
80
|
)
|
|
60
81
|
process.exit(1)
|
|
61
82
|
}
|
|
83
|
+
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http'
|
|
84
|
+
const port = await choosePort(HOST, DEFAULT_PORT)
|
|
85
|
+
const urls = prepareUrls(protocol, HOST, port)
|
|
62
86
|
const nextConfig = linkLoaderConfigBuilder({
|
|
63
87
|
config,
|
|
64
88
|
linkAll: program.linkAll,
|
|
65
89
|
packagesToLink
|
|
66
90
|
})
|
|
67
|
-
const compiler = createCompiler(nextConfig)
|
|
68
|
-
|
|
91
|
+
const compiler = createCompiler(nextConfig, urls)
|
|
92
|
+
const serverConfig = createDevServerConfig(nextConfig, urls.lanUrlForConfig)
|
|
93
|
+
const devServer = new WebpackDevServer(
|
|
94
|
+
{
|
|
95
|
+
...serverConfig,
|
|
96
|
+
port,
|
|
97
|
+
host: HOST
|
|
98
|
+
},
|
|
99
|
+
compiler
|
|
100
|
+
)
|
|
101
|
+
log.processing('❯ Starting the development server...\n')
|
|
102
|
+
devServer.startCallback(err => {
|
|
103
|
+
if (err) return log.error(err)
|
|
104
|
+
;['SIGINT', 'SIGTERM'].forEach(sig => {
|
|
105
|
+
process.on(sig, () => {
|
|
106
|
+
devServer.stop()
|
|
107
|
+
process.exit()
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
})
|
|
69
111
|
}
|
|
70
112
|
|
|
71
|
-
|
|
113
|
+
if (!module.parent) {
|
|
114
|
+
start()
|
|
115
|
+
}
|
|
72
116
|
|
|
73
117
|
module.exports = start
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
const webpack = require('webpack')
|
|
2
|
+
const formatWebpackMessages = require('../utils/formatWebpackMessages')
|
|
3
|
+
const clearConsole = require('../utils/clearConsole')
|
|
2
4
|
const log = require('../shared/log')
|
|
3
5
|
|
|
4
|
-
|
|
6
|
+
const isInteractive = process.stdout.isTTY
|
|
7
|
+
|
|
8
|
+
const printInstructions = ({urls}) =>
|
|
9
|
+
log.info(`
|
|
10
|
+
Local: ${urls.localUrlForTerminal}
|
|
11
|
+
Network: ${urls.lanUrlForTerminal}
|
|
12
|
+
`)
|
|
13
|
+
|
|
14
|
+
module.exports = (config, urls) => {
|
|
5
15
|
let compiler
|
|
6
16
|
try {
|
|
7
|
-
log.processing('❯ Compiling...')
|
|
8
17
|
compiler = webpack(config)
|
|
9
18
|
} catch (err) {
|
|
10
19
|
log.error(`✖ Failed to compile:\n ${err.message || err}`)
|
|
@@ -12,23 +21,28 @@ module.exports = config => {
|
|
|
12
21
|
}
|
|
13
22
|
|
|
14
23
|
compiler.hooks.invalid.tap('invalid', () => {
|
|
24
|
+
if (isInteractive) clearConsole()
|
|
15
25
|
log.processing('❯ Compiling...')
|
|
16
26
|
})
|
|
17
27
|
|
|
18
28
|
compiler.hooks.done.tap('done', stats => {
|
|
29
|
+
if (isInteractive) clearConsole()
|
|
30
|
+
|
|
19
31
|
const isSuccessful = !stats.hasErrors()
|
|
20
32
|
|
|
21
33
|
// Log the correct message of compilation depending if we have warnings
|
|
22
34
|
if (isSuccessful) {
|
|
23
|
-
const {time} = stats.toJson('minimal')
|
|
24
35
|
stats.hasWarnings()
|
|
25
|
-
? log.warn(
|
|
26
|
-
: log.success(
|
|
36
|
+
? log.warn('⚠ Compiled with warnings')
|
|
37
|
+
: log.success('✔ Compiled successfully')
|
|
27
38
|
}
|
|
28
39
|
|
|
40
|
+
// Even with warnings, we show instructions to access localhost if we have a compilation
|
|
41
|
+
if (isSuccessful && isInteractive) printInstructions({urls})
|
|
42
|
+
|
|
29
43
|
// If we have errors, we must show them
|
|
30
44
|
if (!isSuccessful) {
|
|
31
|
-
const messages =
|
|
45
|
+
const messages = formatWebpackMessages(stats.toJson('errors-only', true))
|
|
32
46
|
// Only keep the first error. Others are often indicative
|
|
33
47
|
// of the same problem, but confuse the reader with noise.
|
|
34
48
|
if (messages.errors.length > 1) messages.errors.length = 1
|
|
@@ -38,7 +52,9 @@ module.exports = config => {
|
|
|
38
52
|
|
|
39
53
|
// With warnings, even after showing the instructions we must list the warnings we have
|
|
40
54
|
if (stats.hasWarnings()) {
|
|
41
|
-
const messages =
|
|
55
|
+
const messages = formatWebpackMessages(
|
|
56
|
+
stats.toJson('errors-warnings', true)
|
|
57
|
+
)
|
|
42
58
|
log.warn(messages.warnings.join('\n\n'))
|
|
43
59
|
}
|
|
44
60
|
})
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware')
|
|
4
|
+
const ignoredFiles = require('react-dev-utils/ignoredFiles')
|
|
5
|
+
|
|
6
|
+
const {HOST, HTTPS} = process.env
|
|
7
|
+
const protocol = HTTPS === 'true' ? 'https' : 'http'
|
|
8
|
+
const host = HOST || '0.0.0.0'
|
|
9
|
+
|
|
10
|
+
const getWatchOptions = ({context, watch}) => {
|
|
11
|
+
return watch
|
|
12
|
+
? {
|
|
13
|
+
ignored: ignoredFiles(context)
|
|
14
|
+
}
|
|
15
|
+
: false
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = config => ({
|
|
19
|
+
allowedHosts: 'all',
|
|
20
|
+
client: {
|
|
21
|
+
logging: 'none',
|
|
22
|
+
overlay: {
|
|
23
|
+
errors: true,
|
|
24
|
+
warnings: false
|
|
25
|
+
},
|
|
26
|
+
progress: true
|
|
27
|
+
},
|
|
28
|
+
static: {
|
|
29
|
+
directory: 'public',
|
|
30
|
+
watch: getWatchOptions(config)
|
|
31
|
+
},
|
|
32
|
+
hot: true,
|
|
33
|
+
https: protocol === 'https',
|
|
34
|
+
host,
|
|
35
|
+
historyApiFallback: {
|
|
36
|
+
disableDotRule: true
|
|
37
|
+
},
|
|
38
|
+
onAfterSetupMiddleware(devServer) {
|
|
39
|
+
// This service worker file is effectively a 'no-op' that will reset any
|
|
40
|
+
// previous service worker registered for the same host:port combination.
|
|
41
|
+
devServer.app.use(noopServiceWorkerMiddleware(config.output.publicPath))
|
|
42
|
+
}
|
|
43
|
+
})
|
|
@@ -60,12 +60,12 @@ module.exports = ({config, packagesToLink, linkAll}) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* Create a sass-loader config for scss files that
|
|
63
|
+
* Create a @s-ui/sass-loader config for scss files that
|
|
64
64
|
* are handled by Sass. These are nested modules imported
|
|
65
65
|
* and thus is sass binary which needs a special config for them.
|
|
66
66
|
*/
|
|
67
67
|
const sassLoaderWithLinkImporter = {
|
|
68
|
-
loader: require.resolve('sass-loader'),
|
|
68
|
+
loader: require.resolve('@s-ui/sass-loader'),
|
|
69
69
|
options: {
|
|
70
70
|
sassOptions: {
|
|
71
71
|
importer: createSassLinkImporter(entryPoints)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@s-ui/bundler",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.4",
|
|
4
4
|
"description": "Config-free bundler for ES6 React apps.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"sui-bundler": "./bin/sui-bundler.js"
|
|
@@ -21,30 +21,30 @@
|
|
|
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
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"@s-ui/sass-loader": "1",
|
|
27
|
+
"autoprefixer": "10.4.0",
|
|
28
|
+
"babel-loader": "8.2.3",
|
|
28
29
|
"babel-preset-sui": "3",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"css-
|
|
32
|
-
"
|
|
33
|
-
"fast-glob": "3.2.
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"postcss-loader": "4.1.0",
|
|
30
|
+
"commander": "8.3.0",
|
|
31
|
+
"css-loader": "6.5.1",
|
|
32
|
+
"css-minimizer-webpack-plugin": "3.1.3",
|
|
33
|
+
"esbuild-loader": "2.16.0",
|
|
34
|
+
"fast-glob": "3.2.7",
|
|
35
|
+
"html-webpack-plugin": "5.5.0",
|
|
36
|
+
"mini-css-extract-plugin": "2.4.4",
|
|
37
|
+
"process": "0.11.10",
|
|
38
|
+
"postcss": "8.3.11",
|
|
39
|
+
"postcss-loader": "6.2.0",
|
|
40
|
+
"react-dev-utils": "11.0.4",
|
|
41
41
|
"rimraf": "3.0.2",
|
|
42
|
-
"sass": "1.
|
|
43
|
-
"
|
|
44
|
-
"style-loader": "
|
|
45
|
-
"webpack": "5.
|
|
46
|
-
"webpack-
|
|
47
|
-
"webpack-
|
|
48
|
-
"webpack-
|
|
42
|
+
"sass": "1.43.4",
|
|
43
|
+
"speed-measure-webpack-plugin": "1.5.0",
|
|
44
|
+
"style-loader": "3.3.1",
|
|
45
|
+
"webpack": "5.64.1",
|
|
46
|
+
"webpack-dev-server": "4.5.0",
|
|
47
|
+
"webpack-manifest-plugin": "4.0.2",
|
|
48
|
+
"webpack-node-externals": "3.0.0"
|
|
49
49
|
}
|
|
50
50
|
}
|
package/shared/config.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
const {
|
|
3
3
|
config: packageJsonConfig = {}
|
|
4
4
|
} = require(`${process.cwd()}/package.json`)
|
|
5
|
-
const {'sui-bundler': config = {}} = packageJsonConfig
|
|
6
5
|
|
|
6
|
+
const {'sui-bundler': config = {}} = packageJsonConfig
|
|
7
7
|
const {extractComments, sourcemaps} = config
|
|
8
8
|
|
|
9
9
|
exports.config = config
|
package/shared/log.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk')
|
|
2
|
+
const colors = require('@s-ui/helpers/colors')
|
|
4
3
|
|
|
5
4
|
module.exports = {
|
|
6
|
-
info: msg => console.log(
|
|
7
|
-
error: msg => console.log(
|
|
8
|
-
success: msg => console.log(
|
|
9
|
-
warn: msg => console.log(
|
|
10
|
-
processing: msg => console.log(
|
|
5
|
+
info: msg => console.log(colors.gray(msg)),
|
|
6
|
+
error: msg => console.log(colors.red(msg)),
|
|
7
|
+
success: msg => console.log(colors.green(msg)),
|
|
8
|
+
warn: msg => console.log(colors.yellow(msg)),
|
|
9
|
+
processing: msg => console.log(colors.cyan(msg))
|
|
11
10
|
}
|
package/shared/minify-css.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin')
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const createCssMinimizerPlugin = () =>
|
|
4
4
|
new CssMinimizerPlugin({
|
|
5
5
|
minimizerOptions: {
|
|
6
6
|
preset: [
|
|
@@ -11,3 +11,5 @@ module.exports = () =>
|
|
|
11
11
|
]
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
|
+
|
|
15
|
+
module.exports = () => createCssMinimizerPlugin()
|
package/shared/minify-js.js
CHANGED
|
@@ -1,47 +1,10 @@
|
|
|
1
|
-
const
|
|
2
|
-
const {CI = false} = process.env
|
|
3
|
-
const CI_PARALLEL_CORES = 2
|
|
1
|
+
const {ESBuildMinifyPlugin} = require('esbuild-loader')
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
new
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
parse: {
|
|
10
|
-
// we want terser to parse ecma 8 code. However, we don't want it
|
|
11
|
-
// to apply any minfication steps that turns valid ecma 5 code
|
|
12
|
-
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
13
|
-
// sections only apply transformations that are ecma 5 safe
|
|
14
|
-
// https://github.com/facebook/create-react-app/pull/4234
|
|
15
|
-
ecma: 8
|
|
16
|
-
},
|
|
17
|
-
compress: {
|
|
18
|
-
ecma: 5,
|
|
19
|
-
warnings: false,
|
|
20
|
-
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
21
|
-
// https://github.com/facebook/create-react-app/issues/2376
|
|
22
|
-
// Pending further investigation:
|
|
23
|
-
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
24
|
-
comparisons: false,
|
|
25
|
-
// Disabled because of an issue with Terser breaking valid code:
|
|
26
|
-
// https://github.com/facebook/create-react-app/issues/5250
|
|
27
|
-
// Pending futher investigation:
|
|
28
|
-
// https://github.com/terser-js/terser/issues/120
|
|
29
|
-
inline: 2
|
|
30
|
-
},
|
|
31
|
-
mangle: {
|
|
32
|
-
safari10: true
|
|
33
|
-
},
|
|
34
|
-
output: {
|
|
35
|
-
ecma: 5,
|
|
36
|
-
comments: false,
|
|
37
|
-
// Turned on because emoji and regex is not minified properly using default
|
|
38
|
-
// https://github.com/facebook/create-react-app/issues/2488
|
|
39
|
-
ascii_only: true
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
// Use multi-process parallel running to improve the build speed
|
|
43
|
-
// For CI: Use only fixed cores as it gives incorrect info and could cause troubles
|
|
44
|
-
// Related: https://github.com/webpack-contrib/terser-webpack-plugin/issues/202
|
|
45
|
-
// If not CI then use os.cpus().length - 1
|
|
46
|
-
parallel: CI ? CI_PARALLEL_CORES : true
|
|
3
|
+
const esbuild = ({sourceMap}) =>
|
|
4
|
+
new ESBuildMinifyPlugin({
|
|
5
|
+
target: 'es6',
|
|
6
|
+
sourcemap: sourceMap !== 'none' && sourceMap !== false
|
|
47
7
|
})
|
|
8
|
+
|
|
9
|
+
module.exports = ({extractComments, sourceMap}) =>
|
|
10
|
+
esbuild({extractComments, sourceMap})
|
package/shared/resolve-alias.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
8
|
+
const fs = require('fs')
|
|
9
|
+
const path = require('path')
|
|
10
|
+
|
|
11
|
+
function checkRequiredFiles(files) {
|
|
12
|
+
let currentFilePath
|
|
13
|
+
try {
|
|
14
|
+
files.forEach(filePath => {
|
|
15
|
+
currentFilePath = filePath
|
|
16
|
+
fs.accessSync(filePath, fs.F_OK)
|
|
17
|
+
})
|
|
18
|
+
return true
|
|
19
|
+
} catch (err) {
|
|
20
|
+
const dirName = path.dirname(currentFilePath)
|
|
21
|
+
const fileName = path.basename(currentFilePath)
|
|
22
|
+
|
|
23
|
+
console.log('Could not find a required file:')
|
|
24
|
+
console.log(` Name: ${fileName}`)
|
|
25
|
+
console.log(` Searched in: ${dirName}`)
|
|
26
|
+
|
|
27
|
+
return false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = checkRequiredFiles
|