Skip to content

Commit acbc837

Browse files
committed
Merge commit '5cb03bad2195506189c2cefedbf601fd5d3252f7' into version-3
This contains the merge of #129
2 parents 9ea963d + 5cb03ba commit acbc837

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

packages/plugin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"dependencies": {
3232
"@webpack-bundle-analyzer/reporter-treemap": "^3.0.0-alpha.1",
3333
"acorn": "^5.1.1",
34+
"bfj-node4": "^4.2.4",
3435
"chalk": "^1.1.3",
3536
"commander": "^2.9.0",
3637
"ejs": "^2.5.6",

packages/plugin/src/BundleAnalyzerPlugin.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const fs = require('fs');
1+
const bfj = require('bfj-node4');
22
const path = require('path');
33
const mkdir = require('mkdirp');
44
const { bold } = require('chalk');
@@ -69,19 +69,27 @@ class BundleAnalyzerPlugin {
6969
});
7070
}
7171

72-
generateStatsFile(stats) {
72+
async generateStatsFile(stats) {
7373
const statsFilepath = path.resolve(this.compiler.outputPath, this.opts.statsFilename);
74-
7574
mkdir.sync(path.dirname(statsFilepath));
7675

77-
fs.writeFileSync(
78-
statsFilepath,
79-
JSON.stringify(stats, null, 2)
80-
);
76+
try {
77+
await bfj.write(statsFilepath, stats, {
78+
promises: 'ignore',
79+
buffers: 'ignore',
80+
maps: 'ignore',
81+
iterables: 'ignore',
82+
circular: 'ignore'
83+
});
8184

82-
this.logger.info(
83-
`${bold('Webpack Bundle Analyzer')} saved stats file to ${bold(statsFilepath)}`
84-
);
85+
this.logger.info(
86+
`${bold('Webpack Bundle Analyzer')} saved stats file to ${bold(statsFilepath)}`
87+
);
88+
} catch (error) {
89+
this.logger.error(
90+
`${bold('Webpack Bundle Analyzer')} error saving stats file to ${bold(statsFilepath)}: ${error}`
91+
);
92+
}
8593
}
8694

8795
async startAnalyzerServer(stats) {

yarn.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,13 @@ beeper@^1.0.0:
841841
version "1.1.1"
842842
resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809"
843843

844+
bfj-node4@^4.2.4:
845+
version "4.2.4"
846+
resolved "https://registry.yarnpkg.com/bfj-node4/-/bfj-node4-4.2.4.tgz#8484fe2ec73ea195906f3fd26ebd309be233e91a"
847+
dependencies:
848+
check-types "^7.3.0"
849+
tryer "^1.0.0"
850+
844851
big.js@^3.1.3:
845852
version "3.2.0"
846853
resolved "https://registry.yarnpkg.com/big.js/-/big.js-3.2.0.tgz#a5fc298b81b9e0dca2e458824784b65c52ba588e"
@@ -1074,6 +1081,10 @@ chalk@^2.0.0, chalk@^2.1.0:
10741081
escape-string-regexp "^1.0.5"
10751082
supports-color "^4.0.0"
10761083

1084+
check-types@^7.3.0:
1085+
version "7.3.0"
1086+
resolved "https://registry.yarnpkg.com/check-types/-/check-types-7.3.0.tgz#468f571a4435c24248f5fd0cb0e8d87c3c341e7d"
1087+
10771088
chokidar@^1.6.0, chokidar@^1.6.1, chokidar@^1.7.0:
10781089
version "1.7.0"
10791090
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"
@@ -5891,6 +5902,10 @@ trim-right@^1.0.1:
58915902
version "1.0.1"
58925903
resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003"
58935904

5905+
tryer@^1.0.0:
5906+
version "1.0.0"
5907+
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.0.tgz#027b69fa823225e551cace3ef03b11f6ab37c1d7"
5908+
58945909
tryit@^1.0.1:
58955910
version "1.0.3"
58965911
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"

0 commit comments

Comments
 (0)