Socket
Socket
Sign inDemoInstall

rollup-plugin-visualizer

Package Overview
Dependencies
24
Maintainers
1
Versions
105
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.7.1 to 5.8.0

dist/plugin/render-template.d.ts

5

dist/bin/cli.js

@@ -11,3 +11,3 @@ #!/usr/bin/env node

const helpers_1 = require("yargs/helpers");
const build_stats_1 = require("../plugin/build-stats");
const render_template_1 = require("../plugin/render-template");
const template_types_1 = __importDefault(require("../plugin/template-types"));

@@ -78,6 +78,5 @@ const warn_1 = require("../plugin/warn");

};
const fileContent = await (0, build_stats_1.buildHtml)({
const fileContent = await (0, render_template_1.renderTemplate)(template, {
title,
data,
template,
});

@@ -84,0 +83,0 @@ await fs_1.promises.mkdir(path_1.default.dirname(filename), { recursive: true });

6

dist/plugin/data.js

@@ -59,3 +59,7 @@ "use strict";

for (const { id, renderedLength, gzipLength, brotliLength } of modules) {
const bundleModuleUid = mapper.setNodePart(bundleId, id, { renderedLength, gzipLength, brotliLength });
const bundleModuleUid = mapper.setNodePart(bundleId, id, {
renderedLength,
gzipLength,
brotliLength,
});
const trimmedModuleId = mapper.trimProjectRootId(id);

@@ -62,0 +66,0 @@ const pathParts = trimmedModuleId.split(/\\|\//).filter((p) => p !== "");

@@ -62,2 +62,8 @@ import { Plugin, OutputOptions } from "rollup";

projectRoot?: string | RegExp;
/**
* Use rollup .emitFile API to generate files. Could be usefull if you want to output to configured by rollup output dir.
* When this set to true, filename options must be filename and not a path.
*
* @default false
*/
emitFile?: boolean;

@@ -64,0 +70,0 @@ }

@@ -15,6 +15,17 @@ "use strict";

const sourcemap_1 = require("./sourcemap");
const build_stats_1 = require("./build-stats");
const render_template_1 = require("./render-template");
const WARN_SOURCEMAP_DISABLED = "rollup output configuration missing sourcemap = true. You should add output.sourcemap = true or disable sourcemap in this plugin";
const WARN_SOURCEMAP_MISSING = (id) => `${id} missing source map`;
const WARN_JSON_DEPRECATED = 'Option `json` deprecated, please use template: "raw-data"';
const ERR_FILENAME_EMIT = "When using emitFile option, filename must not be path but a filename";
const defaultSizeGetter = () => Promise.resolve(0);
const chooseDefaultFileName = (opts) => {
if (opts.filename)
return opts.filename;
if (opts.json || opts.template === "raw-data")
return "stats.json";
if (opts.template === "list")
return "stats.yml";
return "stats.html";
};
const visualizer = (opts = {}) => {

@@ -26,4 +37,8 @@ return {

opts = typeof opts === "function" ? opts(outputOptions) : opts;
const json = !!opts.json;
const filename = (_a = opts.filename) !== null && _a !== void 0 ? _a : (json ? "stats.json" : "stats.html");
if ("json" in opts) {
this.warn(WARN_JSON_DEPRECATED);
if (opts.json)
opts.template = "raw-data";
}
const filename = (_a = opts.filename) !== null && _a !== void 0 ? _a : chooseDefaultFileName(opts);
const title = (_b = opts.title) !== null && _b !== void 0 ? _b : "RollUp Visualizer";

@@ -114,10 +129,10 @@ const open = !!opts.open;

};
const fileContent = json
? JSON.stringify(data, null, 2)
: await (0, build_stats_1.buildHtml)({
title,
data,
template,
});
const fileContent = await (0, render_template_1.renderTemplate)(template, {
title,
data,
});
if (opts.emitFile) {
if (path_1.default.isAbsolute(filename) || filename.startsWith(".")) {
this.error(ERR_FILENAME_EMIT);
}
this.emitFile({

@@ -124,0 +139,0 @@ type: "asset",

@@ -22,3 +22,8 @@ "use strict";

uid: uniqueId(),
meta: { id: this.trimProjectRootId(moduleId), moduleParts: {}, imported: new Set(), importedBy: new Set() },
meta: {
id: this.trimProjectRootId(moduleId),
moduleParts: {},
imported: new Set(),
importedBy: new Set(),
},
};

@@ -32,3 +37,8 @@ }

uid: uniqueId(),
meta: { id: this.trimProjectRootId(moduleId), moduleParts: {}, imported: new Set(), importedBy: new Set() },
meta: {
id: this.trimProjectRootId(moduleId),
moduleParts: {},
imported: new Set(),
importedBy: new Set(),
},
};

@@ -35,0 +45,0 @@ }

@@ -1,3 +0,3 @@

export declare type TemplateType = "sunburst" | "treemap" | "network";
export declare type TemplateType = "sunburst" | "treemap" | "network" | "raw-data" | "list";
declare const templates: ReadonlyArray<TemplateType>;
export default templates;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const templates = ["sunburst", "treemap", "network"];
const templates = ["sunburst", "treemap", "network", "list", "raw-data"];
exports.default = templates;
{
"name": "rollup-plugin-visualizer",
"version": "5.7.1",
"version": "5.8.0",
"main": "./dist/plugin/index.js",

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

"test:test": "node build.js --all --test",
"test:e2e-json": "node build.js --all --e2e --json",
"test:test-json": "node build.js --all --test --json",
"test:e2e-json-sourcemap": "node build.js --all --e2e --json --sourcemap",
"test:test-json-sourcemap": "node build.js --all --test --json --sourcemap",
"test:cli": "node build.js --dev --all --gzip --brotli --sourcemap --json && node dist/bin/cli.js ./stats.sunburst.json"
"test:e2e-sourcemap": "node build.js --all --e2e --sourcemap",
"test:test-sourcemap": "node build.js --all --test --sourcemap",
"test:cli": "node build.js --dev --all --gzip --brotli --sourcemap --raw-data && node dist/bin/cli.js ./stats.raw-data.json"
},

@@ -35,0 +33,0 @@ "dependencies": {

@@ -54,18 +54,12 @@ # Rollup Plugin Visualizer

Usage with SvelteKit (svelte.config.js)
Usage with SvelteKit (vite.config.js)
```js
import path from "path";
const config = {
kit: {
vite: {
plugins: [
visualizer({
emitFile: true,
file: 'stats.html'
})
]
}
},
plugins: [
visualizer({
emitFile: true,
file: "stats.html",
}),
],
};

@@ -105,16 +99,20 @@

### Raw-data
This template produce JSON output with raw data. Normally it should be used with CLI from this plugin.
### List
Output yml file with all the data, could be good idea to commit this file to track file changes.
## Options
`filename` (string, default `stats.html`) - name of the file with diagram to generate
`filename` (string, default `stats.{ext depending template}`) - name of the file with diagram to generate
`title` (string, default `Rollup Visualizer`) - title tag value
`sourcemap` (boolean, default `false`) - Use sourcemaps to calculate sizes (e.g. after UglifyJs or Terser). **Always add plugin as last option.**
`open` (boolean, default `false`) - Open generated file in default user agent
`template` (string, default `treemap`) - Which diagram type to use: `sunburst`, `treemap`, `network`.
`template` (string, default `treemap`) - Which diagram type to use: `sunburst`, `treemap`, `network`, `raw-data`, `list`.
`json` (boolean, default `false`) - Produce portable json file that can be used with plugin CLI util to generate graph from several json files. Every UI property ignored in this case.
`gzipSize` (boolean, default `false`) - Collect gzip size from source code and display it at chart.

@@ -124,2 +122,8 @@

### Advanced options (touch only if you really need it):
`emitFile` (boolean, default `false`) - Use rollup's `emitFile` to generate file. Useful if you want to control all output in one place (via rollup output options). This also could be usefull with svelte as it calls vite several times.
`sourcemap` (boolean, default `false`) - Use sourcemaps to calculate sizes (e.g. after UglifyJs or Terser). **Always add plugin as last option.**
`projectRoot` (string | RegExp, default `process.cwd()`) - This is some common root(s) path to your files. This is used to cut absolute files paths out.

@@ -126,0 +130,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc