Socket
Socket
Sign inDemoInstall

rollup-plugin-visualizer

Package Overview
Dependencies
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-visualizer - npm Package Compare versions

Comparing version 2.5.0 to 2.5.1

2

package.json
{
"name": "rollup-plugin-visualizer",
"version": "2.5.0",
"version": "2.5.1",
"main": "plugin/index.js",

@@ -5,0 +5,0 @@ "author": "Denis Bardadym <bardadymchik@gmail.com>",

@@ -71,5 +71,70 @@ "use strict";

return { start, links, nodes, groups };
return { start, links, nodes, groups, commonPrefix };
};
module.exports = buildGraph;
const mergeGraphs = (id, graphs) => {
let groupId = 0;
const newGroups = {};
const firstGraph = graphs[0].root;
let commonCommonPrefix = firstGraph.commonPrefix;
const reMapGroups = new Map();
for (const { root } of graphs) {
const { groups, commonPrefix } = root;
const reMappedGroups = { "0": 0 };
for (const [moduleName, prevGroupId] of Object.entries(groups)) {
if (newGroups[moduleName] == null) {
newGroups[moduleName] = ++groupId;
}
reMappedGroups[prevGroupId] = newGroups[moduleName];
}
for (let i = 0; i < commonCommonPrefix.length && i < commonPrefix.length; i++) {
if (commonCommonPrefix[i] !== commonPrefix[i]) {
commonCommonPrefix = commonCommonPrefix.slice(0, i);
break;
}
}
reMapGroups.set(root, reMappedGroups);
}
const newLinks = [];
const newNodes = {};
for (const { root } of graphs) {
const { links, nodes, commonPrefix } = root;
const notCommonPrefix = commonPrefix.slice(commonCommonPrefix.length);
const reMappedGroups = reMapGroups.get(root);
for (const [id, mod] of Object.entries(nodes)) {
newNodes[notCommonPrefix + id] = mod;
mod.group = reMappedGroups[mod.group];
}
for (const { source, target } of links) {
newLinks.push({ source: notCommonPrefix + source, target: notCommonPrefix + target });
}
}
const notCommonPrefix = firstGraph.commonPrefix.slice(commonCommonPrefix.length);
const newStart = notCommonPrefix + firstGraph.start;
return {
id,
root: {
groups: newGroups,
nodes: newNodes,
links: newLinks,
start: newStart,
commonPrefix: commonCommonPrefix
}
};
};
module.exports = { buildGraph, mergeGraphs };

@@ -75,2 +75,12 @@ "use strict";

module.exports = buildTree;
const mergeTrees = (id, trees) => {
return {
id,
root: {
name: "root",
children: trees.map(({ id, root }) => ({ name: id, children: root.children }))
}
};
};
module.exports = { buildTree, mergeTrees };

@@ -15,4 +15,4 @@ "use strict";

const buildStats = require("./build-stats");
const buildTree = require("./hierarchy");
const buildGraph = require("./graph");
const { buildTree, mergeTrees } = require("./hierarchy");
const { buildGraph, mergeGraphs } = require("./graph");
const addMinifiedSizesToModules = require("./sourcemap");

@@ -57,2 +57,4 @@

const dataType = DATA_TYPE_FOR_TEMPLATE[template];
for (const [id, bundle] of Object.entries(outputBundle)) {

@@ -78,3 +80,3 @@ if (bundle.isAsset) continue; //only chunks

let root = null;
switch (DATA_TYPE_FOR_TEMPLATE[template]) {
switch (dataType) {
case HIERARCHY: {

@@ -100,14 +102,18 @@ root = buildTree(Object.keys(bundle.modules), getInitialModuleData);

const id = "bundles";
if (bundlesRelative) {
roots = [
{
id: "bundles",
root: {
name: "root",
children: roots.map(({ id, root }) => ({ name: id, children: root.children }))
}
switch (dataType) {
case HIERARCHY: {
roots = mergeTrees(id, roots);
break;
}
];
case GRAPH: {
roots = mergeGraphs(id, roots);
break;
}
}
}
roots = [roots];
const html = await buildStats(title, roots, template);

@@ -114,0 +120,0 @@

@@ -56,4 +56,13 @@ # Rollup Plugin Visualizer

## Disclaimer about generated files
Generated files does not and never will be contain your source code (contents of files). They can contains only js/html/css code required to build chart (plugin code) and statistical information about your source code.
This statistical information can contain:
* byte size of files included in bundled
* size of files included in source map
* file's path
* files hierarchy (fs tree for your files)
## Acknowledgements
Initially this plugin was based on `webpack-visualizer`, but in the end used only styles and layout. Thanks to the tons of people around internet for great examples of d3 usage. Also i would like to thank you Mike Bostock for awesome D3, and tons of examples.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc