Skip to content

Commit

Permalink
Ensure we don't fallback if renderedLength === 0
Browse files Browse the repository at this point in the history
  • Loading branch information
doesdev committed Jun 7, 2018
1 parent 746db48 commit 7dc5b4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ const analyze = (bundle, opts = {}, format = false) => {

let modules = bundleModules.map((m, i) => {
let id = m.id.replace(root, '');
let size = m.renderedLength || Buffer.byteLength(m.code, 'utf8') || 0;
let size = m.renderedLength;
if (!size && size !== 0) {
size = m.code ? Buffer.byteLength(m.code, 'utf8') : 0;
}
bundleSize += size;

if (Array.isArray(filter) && !filter.some((f) => id.match(f))) return null
Expand Down
5 changes: 4 additions & 1 deletion module.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export const analyze = (bundle, opts = {}, format = false) => {

let modules = bundleModules.map((m, i) => {
let id = m.id.replace(root, '')
let size = m.renderedLength || Buffer.byteLength(m.code, 'utf8') || 0
let size = m.renderedLength
if (!size && size !== 0) {
size = m.code ? Buffer.byteLength(m.code, 'utf8') : 0
}
bundleSize += size

if (Array.isArray(filter) && !filter.some((f) => id.match(f))) return null
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollup-analyzer",
"version": "2.0.0-beta.1",
"version": "2.0.0-beta.2",
"description": "Analyze file sizes of rollup bundled imports",
"main": "index.js",
"module": "module.js",
Expand Down

0 comments on commit 7dc5b4e

Please sign in to comment.