rollup-plugin-visualizer
Advanced tools
Comparing version 0.2.1 to 0.3.0
{ | ||
"name": "rollup-plugin-visualizer", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"main": "plugin.js", | ||
@@ -20,3 +20,5 @@ "author": "Denis Bardadym <bardadymchik@gmail.com>", | ||
}, | ||
"dependencies": {}, | ||
"dependencies": { | ||
"source-map": "^0.5.6" | ||
}, | ||
"devDependencies": { | ||
@@ -29,8 +31,7 @@ "bytes": "^2.4.0", | ||
"eslint": "^3.8.1", | ||
"eslint-plugin-react": "^3.5.1", | ||
"rollup": "^0.36.3", | ||
"rollup-plugin-commonjs": "^5.0.5", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"rollup-plugin-uglify": "^1.0.1" | ||
"rollup": "^0.43.0", | ||
"rollup-plugin-commonjs": "^8.0.2", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-uglify": "^2.0.1" | ||
} | ||
} |
@@ -1,14 +0,13 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const SourceMapConsumer = require('source-map').SourceMapConsumer; | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const SourceMapConsumer = require("source-map").SourceMapConsumer; | ||
const cssString = fs.readFileSync(path.join(__dirname, 'lib', './style.css'), 'utf8'); | ||
const jsString = fs.readFileSync(path.join(__dirname, 'lib', './pluginmain.js'), 'utf8'); | ||
const cssString = fs.readFileSync(path.join(__dirname, "lib", "./style.css"), "utf8"); | ||
const jsString = fs.readFileSync(path.join(__dirname, "lib", "./pluginmain.js"), "utf8"); | ||
const COMMONJS_PLUGIN_PREFIX = '\u0000commonjs-proxy:'; | ||
const PLUGIN_PREFIX = "\u0000"; | ||
module.exports = function(opts) { | ||
opts = opts || {}; | ||
var filename = opts.filename || 'stats.html'; | ||
var filename = opts.filename || "stats.html"; | ||
var useSourceMap = !!opts.sourcemap; | ||
@@ -21,3 +20,3 @@ | ||
var root = { | ||
name: 'root', | ||
name: "root", | ||
children: [] | ||
@@ -34,18 +33,11 @@ }; | ||
//dependencies: module.dependencies, | ||
size: useSourceMap ? (module.minifiedSize || 0) : Buffer.byteLength(module.code, 'utf8'), | ||
originalSize: Buffer.byteLength(module.originalCode, 'utf8') | ||
size: useSourceMap ? module.minifiedSize || 0 : Buffer.byteLength(module.code, "utf8"), | ||
originalSize: Buffer.byteLength(module.originalCode, "utf8") | ||
}; | ||
if (name.indexOf(COMMONJS_PLUGIN_PREFIX) === 0) { | ||
m.name = COMMONJS_PLUGIN_PREFIX; | ||
m = { | ||
plugin: [ | ||
m | ||
] | ||
}; | ||
name = name.substr(COMMONJS_PLUGIN_PREFIX.length); | ||
if (name.indexOf(PLUGIN_PREFIX) === 0) { | ||
addToPath(root, name, m); | ||
} else { | ||
addToPath(root, name.split(path.sep), m); | ||
} | ||
addToPath(root, name.split(path.sep), m); | ||
}); | ||
@@ -88,6 +80,6 @@ flattenTree(root); | ||
} | ||
// if root children have only on child we can flatten this | ||
// if root children have only on child we can flatten this | ||
function flattenTree(root) { | ||
var newChildren = []; | ||
root.children.forEach((child) => { | ||
root.children.forEach(child => { | ||
var commonParent = getDeepMoreThenOneChild(child); | ||
@@ -99,5 +91,4 @@ newChildren = newChildren.concat(commonParent.children); | ||
function addToPath(tree, p, value) { | ||
if (p[0] === '') { | ||
if (p[0] === "") { | ||
p.shift(); | ||
@@ -132,3 +123,3 @@ } | ||
var result = map.originalPositionFor({ line: line + 1, column: col }); | ||
var source = result.source || 'root'; | ||
var source = result.source || "root"; | ||
if (!bytesPerFile[source]) { | ||
@@ -140,8 +131,5 @@ bytesPerFile[source] = 0; | ||
} | ||
return Object.keys(bytesPerFile).map(file => | ||
({ file: path.resolve(file), bytes: bytesPerFile[file] })); | ||
return Object.keys(bytesPerFile).map(file => ({ file: path.resolve(file), bytes: bytesPerFile[file] })); | ||
} | ||
// Given a file C:/path/to/file/on/filesystem.js | ||
@@ -191,4 +179,6 @@ // - remove extension | ||
var module = findBestMatchingModule(tuple.file); | ||
if (module) {module.minifiedSize = tuple.bytes;} | ||
if (module) { | ||
module.minifiedSize = tuple.bytes; | ||
} | ||
}); | ||
} |
Sorry, the diff of this file is too big to display
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10
73268
1
496
+ Addedsource-map@^0.5.6
+ Addedsource-map@0.5.7(transitive)