@s-ui/bundler 9.23.0 → 9.24.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-analyzer.js +11 -44
- package/package.json +1 -1
|
@@ -4,58 +4,25 @@
|
|
|
4
4
|
const webpack = require('webpack')
|
|
5
5
|
const log = require('../shared/log.js')
|
|
6
6
|
const config = require('../webpack.config.prod.js')
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const installNeededDependencies = async () => {
|
|
11
|
-
try {
|
|
12
|
-
require('webpack-bundle-analyzer')
|
|
13
|
-
return true
|
|
14
|
-
} catch (e) {
|
|
15
|
-
logUpdate('Installing needed dependencies...')
|
|
16
|
-
return getSpawnPromise('npm', [
|
|
17
|
-
'install',
|
|
18
|
-
'--no-save',
|
|
19
|
-
'--no-audit',
|
|
20
|
-
'--no-fund',
|
|
21
|
-
'webpack-bundle-analyzer@4.5.0 duplicate-package-checker-webpack-plugin@3.0.0'
|
|
22
|
-
]).then(() => {
|
|
23
|
-
logUpdate.done('Installed needed dependencies')
|
|
24
|
-
getSpawnPromise('./node_modules/.bin/sui-bundler', ['analyzer']).then(
|
|
25
|
-
() => false
|
|
26
|
-
)
|
|
27
|
-
})
|
|
28
|
-
}
|
|
29
|
-
}
|
|
7
|
+
const fs = require('fs')
|
|
8
|
+
const {getSpawnPromise} = require('@s-ui/helpers/cli.js')
|
|
30
9
|
|
|
31
10
|
;(async () => {
|
|
32
|
-
const keepExecution = await installNeededDependencies()
|
|
33
|
-
if (!keepExecution) return
|
|
34
|
-
|
|
35
|
-
const {BundleAnalyzerPlugin} = require('webpack-bundle-analyzer')
|
|
36
|
-
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin')
|
|
37
|
-
|
|
38
|
-
config.plugins.push(new BundleAnalyzerPlugin())
|
|
39
|
-
config.plugins.push(
|
|
40
|
-
new DuplicatePackageCheckerPlugin({
|
|
41
|
-
verbose: true, // Show module that is requiring each duplicate package
|
|
42
|
-
emitError: false // Avoid emit errors, just a warning
|
|
43
|
-
})
|
|
44
|
-
)
|
|
45
|
-
|
|
46
11
|
log.processing('🔎 Analyzing Bundle...\n')
|
|
47
|
-
webpack(config).run((error, stats) => {
|
|
12
|
+
webpack({...config, profile: true, stats: true}).run((error, stats) => {
|
|
48
13
|
if (error) {
|
|
49
14
|
log.error('Error analyzing the build')
|
|
50
15
|
throw new Error(error)
|
|
51
16
|
}
|
|
52
17
|
|
|
53
|
-
log.success('
|
|
18
|
+
log.success('Compilation done!')
|
|
54
19
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
20
|
+
const filePath = `${process.cwd()}/public/stats.json`
|
|
21
|
+
|
|
22
|
+
fs.writeFileSync(filePath, JSON.stringify(stats.toJson()), {
|
|
23
|
+
encoding: 'utf8'
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
getSpawnPromise('npx --yes webpack-bundle-analyzer', [filePath])
|
|
60
27
|
})
|
|
61
28
|
})()
|