Comments (19)
Not sure if it helps, but we get the same error when running the CLI tool against a stats.json file as well. Managed to get it running by disabling the DedupePlugin
.
from webpack-bundle-analyzer.
Same here. And disabling Dedupe plugin helped as well. Although it won't be the same as real bundle in my understanding.
from webpack-bundle-analyzer.
@Diokuz do you use Dedupe plugin for your production build as well?
from webpack-bundle-analyzer.
@th0r and I tried to run production build with minification, but analyzer still shows unminified sizes (in megabytes).
from webpack-bundle-analyzer.
I did some research on this bug, I am using code splitting in my project , so I have the chunk files those are loaded using webpackJsonp , following code is used to calculate the size of those generated assets
if (_.get(node, 'callee.name') === 'webpackJsonp') {
state.sizes = getModulesSizesFromFunctionArgument(args[1]);
return;
}
function getModulesSizesFromFunctionArgument(arg) {
if (arg.type === 'ObjectExpression') {
const modulesNodes = arg.properties;
return _.transform(modulesNodes, (result, moduleNode) => {
const moduleId = moduleNode.key.name || moduleNode.key.value;
const moduleBody = moduleNode.value.body;
result[moduleId] = moduleBody.end - moduleBody.start;
}, {});
}
if (arg.type === 'ArrayExpression') {
const modulesNodes = arg.elements;
return _.transform(modulesNodes, (result, moduleNode, i) => {
if (!moduleNode) return;
result[i] = moduleNode.body.end - moduleNode.body.start;
}, {});
}
return {};
}
Problem exist in these two lines, which are pre assuming all the node types are function expressions, but there can be Array Nodes or Literal Nodes for those there wont be any body in AST
result[moduleId] = moduleBody.end - moduleBody.start;
result[i] = moduleNode.body.end - moduleNode.body.start;
@th0r above thing might be helpful to fix. this issue can be reproduced if all the asset files exist in the bundle directory.
Cheers
from webpack-bundle-analyzer.
@kishorevarma thanks! Thats exactly what I was thinking of.
but there can be Array Nodes or Literal Nodes
Do you know in which situations they can be arrays or literals?
from webpack-bundle-analyzer.
@Diokuz @alexindigo @balanceiskey
Can someone of you guys send me archive with broken bundle? Everything that webpack has created + stats file.
from webpack-bundle-analyzer.
@th0r yes, we are using new webpack.optimize.DedupePlugin()
. Analyzer started to work when I disabled DedupePlugin.
Can someone of you guys send me archive with broken bundle? Everything that webpack has created + stats file.
Sorry, I cannot do this, our project is not open source ((
from webpack-bundle-analyzer.
I had the same issue, and the culprit was indeed webpack.optimize.DedupePlugin
.
Note that I have the error when running webpack --profile --json
which, if I understood correctly, is unrelated to this tool, actually.
Ah, now that I updated Webpack from 1.12.13 to 1.13.3, I no longer have the issue.
Funnily, when I removed the dedupe plugin for tests, I observed the same size of files generated in production. Looks like it is no longer necessary, at least with NPM 3, I guess.
from webpack-bundle-analyzer.
So, appears that if one module is duplicate of another (has the same content) DedupePlugin
replaces it's content with just module id in output bundle.
But seems like there is another case when module can be an object.
@sokra Could you explain this case please?
from webpack-bundle-analyzer.
Released v1.4.1
with partial support for DedupePlugin
(simple case with duplicated module ids).
Can you check it guys?
from webpack-bundle-analyzer.
@Diokuz @PhiLhoSoft @alexindigo @balanceiskey
Could you check if v1.4.1
solves a problem?
from webpack-bundle-analyzer.
Alas, as said, since I upgraded my libraries and tools, I can no longer reproduce the issue (which is already a good thing, no?).
from webpack-bundle-analyzer.
@PhiLhoSoft I thought you had to remove DedupePlugin
from config?
from webpack-bundle-analyzer.
@th0r its fixed my issue, having array expression in assets files.
from webpack-bundle-analyzer.
having array expression in assets files
Do you mean array in place of module wrapper?
from webpack-bundle-analyzer.
yeah exactly, following solved my issue :) thanks for that
function getModuleSize(node) {
if (node.type === 'FunctionExpression') {
return node.body.end - node.body.start;
}
if (node.type === 'Literal') {
return node.end - node.start;
}
// Fallback for unknown node types
return 0;
}
from webpack-bundle-analyzer.
But seems like there is another case when module can be an object.
@TheLarkInn Need your help here, man)
from webpack-bundle-analyzer.
Released v1.5.2
with full DedupePlugin
support (at least hope so 😜)
from webpack-bundle-analyzer.
Related Issues (20)
- [Question] Chrome performance issue HOT 2
- [Question] Combining statistics into one file (displaying on the same port) for multiple webpack configurations HOT 2
- Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory HOT 2
- opener vulnerability ([email protected] -> [email protected]) HOT 1
- Search should gray out non-matches? HOT 1
- Analyzer page showed different bundle size than browser devtools HOT 2
- Error generating bundle report: Error parsing bundle asset: 'import' and 'export' may appear only with 'sourceType: module' HOT 1
- Error parsing bundle asset "C:\Projects\re\dist\apps\cart\remoteEntry.js": Cannot use 'import.meta' outside a module (1:2374)
- Crashes on files over 512MB HOT 2
- "Unexpected token" when analyzing via packtracker
- Incorrect size when using Webpack's `BannerPlugin` HOT 5
- How to use this repo to analyze some web extensions?
- Bundle parsing breaks if bundled code creates a sequence HOT 4
- Could't analyze webpack bundle: TypeError: Cannot read properties of undefined (reading 'filter') HOT 4
- Override analyzerMode via environment variable
- Support built-in Typescript declarations HOT 1
- Update "ws" package dependency to version 7.4.6 or greater HOT 1
- Filter by entry point HOT 1
- Missing assets section of webpack-stats in ci github action agent build
- Support for vite? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-bundle-analyzer.