webpack-bundle-analyzer 2.8.3 → 2.10.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.
@@ -1,4 +1,4 @@
1
- const fs = require('fs');
1
+ const bfj = require('bfj-node4');
2
2
  const path = require('path');
3
3
  const mkdir = require('mkdirp');
4
4
  const { bold } = require('chalk');
@@ -61,19 +61,27 @@ class BundleAnalyzerPlugin {
61
61
  });
62
62
  }
63
63
 
64
- generateStatsFile(stats) {
64
+ async generateStatsFile(stats) {
65
65
  const statsFilepath = path.resolve(this.compiler.outputPath, this.opts.statsFilename);
66
-
67
66
  mkdir.sync(path.dirname(statsFilepath));
68
67
 
69
- fs.writeFileSync(
70
- statsFilepath,
71
- JSON.stringify(stats, null, 2)
72
- );
68
+ try {
69
+ await bfj.write(statsFilepath, stats, {
70
+ promises: 'ignore',
71
+ buffers: 'ignore',
72
+ maps: 'ignore',
73
+ iterables: 'ignore',
74
+ circular: 'ignore'
75
+ });
73
76
 
74
- this.logger.info(
75
- `${bold('Webpack Bundle Analyzer')} saved stats file to ${bold(statsFilepath)}`
76
- );
77
+ this.logger.info(
78
+ `${bold('Webpack Bundle Analyzer')} saved stats file to ${bold(statsFilepath)}`
79
+ );
80
+ } catch (error) {
81
+ this.logger.error(
82
+ `${bold('Webpack Bundle Analyzer')} error saving stats file to ${bold(statsFilepath)}: ${error}`
83
+ );
84
+ }
77
85
  }
78
86
 
79
87
  async startAnalyzerServer(stats) {
package/src/analyzer.js CHANGED
@@ -141,7 +141,7 @@ function getModulePath(module) {
141
141
  // Removing first `.`
142
142
  .slice(1)
143
143
  // Replacing `~` with `node_modules`
144
- .map(part => (part === '~') ? 'node_modules' : part);
144
+ .map(part => (part === '~' ? 'node_modules' : part));
145
145
 
146
146
  return parsedPath.length ? parsedPath : null;
147
147
  }
package/src/parseUtils.js CHANGED
@@ -144,7 +144,7 @@ function isArgumentArrayConcatContainingChunks(arg) {
144
144
  function isModuleWrapper(node) {
145
145
  return (
146
146
  // It's an anonymous function expression that wraps module
147
- (node.type === 'FunctionExpression' && !node.id) ||
147
+ ((node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') && !node.id) ||
148
148
  // If `DedupePlugin` is used it can be an ID of duplicated module...
149
149
  isModuleId(node) ||
150
150
  // or an array of shape [<module_id>, ...args]
package/src/viewer.js CHANGED
@@ -74,6 +74,15 @@ async function startServer(bundleStats, opts) {
74
74
 
75
75
  const wss = new WebSocket.Server({ server });
76
76
 
77
+ wss.on('connection', ws => {
78
+ ws.on('error', err => {
79
+ // Ignore network errors like `ECONNRESET`, `EPIPE`, etc.
80
+ if (err.errno) return;
81
+
82
+ logger.info(err.message);
83
+ });
84
+ });
85
+
77
86
  return {
78
87
  ws: wss,
79
88
  http: server,