rollup-plugin-visualizer
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "rollup-plugin-visualizer", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "plugin.js", | ||
@@ -5,0 +5,0 @@ "author": "Denis Bardadym <bardadymchik@gmail.com>", |
@@ -17,5 +17,6 @@ const fs = require('fs'); | ||
return { | ||
ongenerate({ bundle }, rendered) { | ||
ongenerate(args, rendered) { | ||
var bundle = args.bundle; | ||
let root = { | ||
var root = { | ||
name: 'root', | ||
@@ -30,4 +31,4 @@ children: [] | ||
bundle.modules.forEach(module => { | ||
let name = module.id; | ||
let m = { | ||
var name = module.id; | ||
var m = { | ||
//dependencies: module.dependencies, | ||
@@ -89,5 +90,5 @@ size: useSourceMap ? (module.minifiedSize || 0) : Buffer.byteLength(module.code, 'utf8'), | ||
function flattenTree(root) { | ||
let newChildren = []; | ||
var newChildren = []; | ||
root.children.forEach((child) => { | ||
let commonParent = getDeepMoreThenOneChild(child); | ||
var commonParent = getDeepMoreThenOneChild(child); | ||
newChildren = newChildren.concat(commonParent.children); | ||
@@ -104,3 +105,3 @@ }); | ||
let child = tree.children.filter(c => c.name === p[0])[0]; | ||
var child = tree.children.filter(c => c.name === p[0])[0]; | ||
if (!child) { | ||
@@ -122,13 +123,12 @@ child = { | ||
function getBytesPerFileUsingSourceMap(rendered) { | ||
var map = new SourceMapConsumer(rendered.map); | ||
var lines = rendered.code.split(/[\r\n]/); | ||
let map = new SourceMapConsumer(rendered.map); | ||
let lines = rendered.code.split(/[\r\n]/); | ||
var bytesPerFile = {}; | ||
let bytesPerFile = {}; | ||
// For every byte in the minified code, do a sourcemap lookup. | ||
for (let line = 0; line < lines.length; line++) { | ||
for (let col = 0; col < lines[line].length; col++) { | ||
let result = map.originalPositionFor({ line: line + 1, column: col }); | ||
let source = result.source || 'root'; | ||
for (var line = 0; line < lines.length; line++) { | ||
for (var col = 0; col < lines[line].length; col++) { | ||
var result = map.originalPositionFor({ line: line + 1, column: col }); | ||
var source = result.source || 'root'; | ||
if (!bytesPerFile[source]) { | ||
@@ -152,4 +152,4 @@ bytesPerFile[source] = 0; | ||
function segments(filepath) { | ||
let parsed = path.parse(filepath); | ||
let dirWithoutRoot = parsed.dir.substring(parsed.root.length); | ||
var parsed = path.parse(filepath); | ||
var dirWithoutRoot = parsed.dir.substring(parsed.root.length); | ||
@@ -164,13 +164,13 @@ return dirWithoutRoot.split(path.sep).concat(parsed.name).reverse(); | ||
function addMinifiedSizesToModules(bundle, rendered) { | ||
let fileSizes = getBytesPerFileUsingSourceMap(rendered); | ||
var fileSizes = getBytesPerFileUsingSourceMap(rendered); | ||
const findBestMatchingModule = filename => { | ||
let filenameSegments = segments(filename); | ||
var filenameSegments = segments(filename); | ||
for (let i = 1; i <= filenameSegments.length; i++) { | ||
let leftVals = filenameSegments.slice(0, i); | ||
for (var i = 1; i <= filenameSegments.length; i++) { | ||
var leftVals = filenameSegments.slice(0, i); | ||
let matches = bundle.modules.filter(module => { | ||
let moduleSegments = segments(module.id); | ||
let rightVals = moduleSegments.slice(0, i); | ||
var matches = bundle.modules.filter(module => { | ||
var moduleSegments = segments(module.id); | ||
var rightVals = moduleSegments.slice(0, i); | ||
if (rightVals.length !== leftVals.length) { | ||
@@ -191,5 +191,5 @@ return false; | ||
fileSizes.forEach(tuple => { | ||
let module = findBestMatchingModule(tuple.file); | ||
var module = findBestMatchingModule(tuple.file); | ||
if (module) {module.minifiedSize = tuple.bytes;} | ||
}); | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
83666
540