diff --git a/index.js b/index.js index a5f2e33..d99c3bd 100644 --- a/index.js +++ b/index.js @@ -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 diff --git a/module.js b/module.js index b85530d..7516385 100644 --- a/module.js +++ b/module.js @@ -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 diff --git a/package.json b/package.json index 698af05..de55ea4 100644 --- a/package.json +++ b/package.json @@ -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",