Skip to content

Commit a64ebb1

Browse files
committed
create bundle size analysis on build
I think there is room for improvements in distribution bundle size, as zxing is currently distributed directly here as UMD. We could possible be in better situation if we could use @zxing/library which is released as ESM modules nowadays. As a helper for that possible endeavour this [webpack-bundle-analyzer](https://www.npmjs.com/package/webpack-bundle-analyzer) plugin creates a static HTML page to dist/report.html during build.
1 parent 8436a42 commit a64ebb1

File tree

3 files changed

+204
-3
lines changed

3 files changed

+204
-3
lines changed

package-lock.json

Lines changed: 193 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"typescript": "^4.3.2",
8181
"typings": "^2.1.1",
8282
"webpack": "^5.37.0",
83+
"webpack-bundle-analyzer": "^4.9.0",
8384
"webpack-cli": "^4.7.0"
8485
},
8586
"remarkConfig": {

webpack.config.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const path = require("path");
2+
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
3+
24

35
module.exports = {
46
// bundling mode
@@ -7,13 +9,13 @@ module.exports = {
79
entry: "./src/index.ts",
810
// output bundles (location)
911
output: {
10-
path: path.resolve( __dirname, "dist" ),
12+
path: path.resolve(__dirname, "dist"),
1113
filename: "html5-qrcode.min.js",
1214
library: "__Html5QrcodeLibrary__",
1315
},
1416
// file resolutions
1517
resolve: {
16-
extensions: [ ".ts", ".js" ],
18+
extensions: [".ts", ".js"],
1719
},
1820
target: "web",
1921
module: {
@@ -28,5 +30,10 @@ module.exports = {
2830
optimization: {
2931
minimize: true,
3032
usedExports: true
31-
}
33+
},
34+
plugins: [
35+
new BundleAnalyzerPlugin({
36+
analyzerMode: "static"
37+
})
38+
]
3239
};

0 commit comments

Comments
 (0)