rollup-plugin-visualizer
Advanced tools
Comparing version 5.5.4 to 5.6.0
# Changelog | ||
## 5.5.0 | ||
* Allow to pass function that return options | ||
## 5.5.3 | ||
@@ -4,0 +8,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { Plugin } from "rollup"; | ||
import { Plugin, OutputOptions } from "rollup"; | ||
import opn from "open"; | ||
@@ -16,3 +16,3 @@ import { TemplateType } from "./template-types"; | ||
} | ||
export declare const visualizer: (opts?: PluginVisualizerOptions) => Plugin; | ||
export declare const visualizer: (opts?: PluginVisualizerOptions | ((outputOptions: OutputOptions) => PluginVisualizerOptions)) => Plugin; | ||
export default visualizer; |
@@ -20,31 +20,31 @@ "use strict"; | ||
const visualizer = (opts = {}) => { | ||
var _a, _b, _c, _d, _e; | ||
const json = !!opts.json; | ||
const filename = (_a = opts.filename) !== null && _a !== void 0 ? _a : (json ? "stats.json" : "stats.html"); | ||
const title = (_b = opts.title) !== null && _b !== void 0 ? _b : "RollUp Visualizer"; | ||
const open = !!opts.open; | ||
const openOptions = (_c = opts.openOptions) !== null && _c !== void 0 ? _c : {}; | ||
const template = (_d = opts.template) !== null && _d !== void 0 ? _d : "treemap"; | ||
const projectRoot = (_e = opts.projectRoot) !== null && _e !== void 0 ? _e : process.cwd(); | ||
const gzipSize = !!opts.gzipSize; | ||
const brotliSize = !!opts.brotliSize; | ||
const gzipSizeGetter = gzipSize | ||
? (0, compress_1.createGzipSizeGetter)(typeof opts.gzipSize === "object" ? opts.gzipSize : {}) | ||
: defaultSizeGetter; | ||
const brotliSizeGetter = brotliSize | ||
? (0, compress_1.createBrotliSizeGetter)(typeof opts.brotliSize === "object" ? opts.brotliSize : {}) | ||
: defaultSizeGetter; | ||
const ModuleLengths = async ({ id, renderedLength, code, }) => { | ||
const result = { | ||
id, | ||
gzipLength: code == null || code == "" ? 0 : await gzipSizeGetter(code), | ||
brotliLength: code == null || code == "" ? 0 : await brotliSizeGetter(code), | ||
renderedLength: code == null || code == "" ? renderedLength : Buffer.byteLength(code, "utf-8"), | ||
}; | ||
return result; | ||
}; | ||
return { | ||
name: "visualizer", | ||
async generateBundle(outputOptions, outputBundle) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e, _f, _g, _h; | ||
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"); | ||
const title = (_b = opts.title) !== null && _b !== void 0 ? _b : "RollUp Visualizer"; | ||
const open = !!opts.open; | ||
const openOptions = (_c = opts.openOptions) !== null && _c !== void 0 ? _c : {}; | ||
const template = (_d = opts.template) !== null && _d !== void 0 ? _d : "treemap"; | ||
const projectRoot = (_e = opts.projectRoot) !== null && _e !== void 0 ? _e : process.cwd(); | ||
const gzipSize = !!opts.gzipSize; | ||
const brotliSize = !!opts.brotliSize; | ||
const gzipSizeGetter = gzipSize | ||
? (0, compress_1.createGzipSizeGetter)(typeof opts.gzipSize === "object" ? opts.gzipSize : {}) | ||
: defaultSizeGetter; | ||
const brotliSizeGetter = brotliSize | ||
? (0, compress_1.createBrotliSizeGetter)(typeof opts.brotliSize === "object" ? opts.brotliSize : {}) | ||
: defaultSizeGetter; | ||
const ModuleLengths = async ({ id, renderedLength, code, }) => { | ||
const result = { | ||
id, | ||
gzipLength: code == null || code == "" ? 0 : await gzipSizeGetter(code), | ||
brotliLength: code == null || code == "" ? 0 : await brotliSizeGetter(code), | ||
renderedLength: code == null || code == "" ? renderedLength : Buffer.byteLength(code, "utf-8"), | ||
}; | ||
return result; | ||
}; | ||
if (opts.sourcemap && !outputOptions.sourcemap) { | ||
@@ -64,3 +64,3 @@ this.warn(WARN_SOURCEMAP_DISABLED); | ||
} | ||
const modules = await (0, sourcemap_1.getSourcemapModules)(bundleId, bundle, (_b = (_a = outputOptions.dir) !== null && _a !== void 0 ? _a : (outputOptions.file && path_1.default.dirname(outputOptions.file))) !== null && _b !== void 0 ? _b : process.cwd()); | ||
const modules = await (0, sourcemap_1.getSourcemapModules)(bundleId, bundle, (_g = (_f = outputOptions.dir) !== null && _f !== void 0 ? _f : (outputOptions.file && path_1.default.dirname(outputOptions.file))) !== null && _g !== void 0 ? _g : process.cwd()); | ||
const moduleRenderInfo = await Promise.all(Object.values(modules).map(({ id, renderedLength }) => { | ||
@@ -83,3 +83,3 @@ var _a; | ||
}); | ||
const facadeModuleId = (_c = bundle.facadeModuleId) !== null && _c !== void 0 ? _c : `${bundleId}-unknown`; | ||
const facadeModuleId = (_h = bundle.facadeModuleId) !== null && _h !== void 0 ? _h : `${bundleId}-unknown`; | ||
const bundleUid = mapper.setNodePart(bundleId, facadeModuleId, bundleSizes); | ||
@@ -86,0 +86,0 @@ mapper.setNodeMeta(facadeModuleId, { isEntry: true }); |
{ | ||
"name": "rollup-plugin-visualizer", | ||
"version": "5.5.4", | ||
"version": "5.6.0", | ||
"main": "./dist/plugin/index.js", | ||
@@ -5,0 +5,0 @@ "author": "Denis Bardadym <bardadymchik@gmail.com>", |
@@ -35,30 +35,45 @@ # Rollup Plugin Visualizer | ||
Es imports: | ||
Import | ||
```javascript | ||
// es | ||
import { visualizer } from 'rollup-plugin-visualizer'; | ||
// or | ||
// cjs | ||
const { visualizer } = require('rollup-plugin-visualizer'); | ||
``` | ||
//... | ||
plugins: [ | ||
// other plugins | ||
// .... | ||
// | ||
visualizer() | ||
], | ||
//... | ||
Usaget with rollup (rollup.config.js) | ||
```js | ||
module.exports = { | ||
plugins: [ | ||
// put it the last one | ||
visualizer() | ||
] | ||
} | ||
``` | ||
Cjs require: | ||
Usage with vite (vite.config.js) | ||
```js | ||
module.exports = { | ||
plugins: [ | ||
visualizer() | ||
], | ||
}; | ||
``` | ||
```javascript | ||
const { visualizer } = require('rollup-plugin-visualizer'); | ||
Usage with SvelteKit (svelte.config.js) | ||
```js | ||
const config = { | ||
kit: { | ||
vite: { | ||
plugins: [ | ||
visualizer(/* TODO add example there */) | ||
], | ||
} | ||
} | ||
}; | ||
//... | ||
plugins: [ | ||
// other plugins | ||
// .... | ||
// | ||
visualizer() | ||
], | ||
//... | ||
export default config; | ||
``` | ||
@@ -65,0 +80,0 @@ |
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
1803877
132