webpack-bundle-analyzer 4.2.0 → 4.4.2

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.
@@ -134,6 +134,9 @@ class BundleAnalyzerPlugin {
134
134
  }
135
135
 
136
136
  getBundleDirFromCompiler() {
137
+ if (typeof this.compiler.outputFileSystem.constructor === 'undefined') {
138
+ return this.compiler.outputPath;
139
+ }
137
140
  switch (this.compiler.outputFileSystem.constructor.name) {
138
141
  case 'MemoryFileSystem':
139
142
  return null;
package/src/analyzer.js CHANGED
@@ -190,7 +190,7 @@ function getBundleModules(bundleStats) {
190
190
 
191
191
  function assetHasModule(statAsset, statModule) {
192
192
  // Checking if this module is the part of asset chunks
193
- return statModule.chunks.some(moduleChunk =>
193
+ return (statModule.chunks || []).some(moduleChunk =>
194
194
  statAsset.chunks.includes(moduleChunk)
195
195
  );
196
196
  }
package/src/viewer.js CHANGED
@@ -3,8 +3,8 @@ const fs = require('fs');
3
3
  const http = require('http');
4
4
 
5
5
  const WebSocket = require('ws');
6
+ const sirv = require('sirv');
6
7
  const _ = require('lodash');
7
- const express = require('express');
8
8
  const {bold} = require('chalk');
9
9
 
10
10
  const Logger = require('./Logger');
@@ -48,22 +48,26 @@ async function startServer(bundleStats, opts) {
48
48
 
49
49
  if (!chartData) return;
50
50
 
51
- const app = express();
52
- app.use(express.static(`${projectRoot}/public`));
53
-
54
- app.get('/', (req, res) => {
55
- res.writeHead(200, {'Content-Type': 'text/html'});
56
- const html = renderViewer({
57
- mode: 'server',
58
- title: resolveTitle(reportTitle),
59
- chartData,
60
- defaultSizes,
61
- enableWebSocket: true
62
- });
63
- return res.end(html);
51
+ const sirvMiddleware = sirv(`${projectRoot}/public`, {
52
+ // disables caching and traverse the file system on every request
53
+ dev: true
64
54
  });
65
55
 
66
- const server = http.createServer(app);
56
+ const server = http.createServer((req, res) => {
57
+ if (req.method === 'GET' && req.url === '/') {
58
+ const html = renderViewer({
59
+ mode: 'server',
60
+ title: resolveTitle(reportTitle),
61
+ chartData,
62
+ defaultSizes,
63
+ enableWebSocket: true
64
+ });
65
+ res.writeHead(200, {'Content-Type': 'text/html'});
66
+ res.end(html);
67
+ } else {
68
+ sirvMiddleware(req, res);
69
+ }
70
+ });
67
71
 
68
72
  await new Promise(resolve => {
69
73
  server.listen(port, host, () => {