vite-bundle-explorer 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -19
- package/dist/assets/index-CgYcK0gG.css +1 -0
- package/dist/assets/index-DHBN8nqM.js +63 -0
- package/dist/index.html +2 -2
- package/package.json +5 -2
- package/plugin/stats-plugin.js +39 -8
- package/dist/assets/index-BajBbEJD.css +0 -1
- package/dist/assets/index-CBo5B8y_.js +0 -63
package/dist/index.html
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>vite-bundle-explorer</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-DHBN8nqM.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CgYcK0gG.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="app"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-bundle-explorer",
|
|
3
|
-
"
|
|
3
|
+
"description": "Bundle analyzer and visualizer tool for Vite",
|
|
4
|
+
"version": "0.2.0",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"homepage": "https://github.com/Solant/vite-bundle-explorer#readme",
|
|
6
7
|
"repository": {
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@unocss/reset": "^66.3.3",
|
|
50
51
|
"@vitejs/plugin-vue": "^6.0.0",
|
|
51
52
|
"@vue/tsconfig": "^0.7.0",
|
|
53
|
+
"@vueuse/core": "^13.5.0",
|
|
52
54
|
"changelogen": "^0.6.2",
|
|
53
55
|
"echarts": "^5.6.0",
|
|
54
56
|
"prettier": "^3.6.2",
|
|
@@ -61,8 +63,9 @@
|
|
|
61
63
|
},
|
|
62
64
|
"scripts": {
|
|
63
65
|
"dev": "vite",
|
|
64
|
-
"build": "vue-tsc -b &&
|
|
66
|
+
"build": "vue-tsc -b && pnpm build:plugin && vite build",
|
|
65
67
|
"build:plugin": "tsc --module Node16 --moduleResolution node16 plugin/stats-plugin.ts",
|
|
68
|
+
"format": "prettier src plugin bin vite.config.ts --write",
|
|
66
69
|
"release": "pnpm build && pnpm changelogen --release --push && pnpm publish"
|
|
67
70
|
}
|
|
68
71
|
}
|
package/plugin/stats-plugin.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { writeFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
|
+
import { gzip } from 'node:zlib';
|
|
4
|
+
import { promisify } from 'node:util';
|
|
5
|
+
const compress = promisify(gzip);
|
|
3
6
|
function upsertNodeIndex(nodes, item) {
|
|
4
7
|
const index = nodes.indexOf(item);
|
|
5
8
|
return index === -1 ? nodes.push(item) - 1 : index;
|
|
@@ -8,6 +11,7 @@ export function statsPlugin() {
|
|
|
8
11
|
let root = '';
|
|
9
12
|
let outDir = '';
|
|
10
13
|
let enabled = true;
|
|
14
|
+
let reportCompressed = false;
|
|
11
15
|
function truncatePath(filePath) {
|
|
12
16
|
let index = 0;
|
|
13
17
|
const normalizedPath = filePath.replaceAll('\u0000', '');
|
|
@@ -19,13 +23,15 @@ export function statsPlugin() {
|
|
|
19
23
|
}
|
|
20
24
|
return index > 0 ? normalizedPath.substring(index + 1) : normalizedPath;
|
|
21
25
|
}
|
|
22
|
-
const
|
|
26
|
+
const edges = new Set();
|
|
27
|
+
const stats = { chunks: [], importGraph: { edges: [] }, moduleFileNames: [] };
|
|
23
28
|
const plugin = {
|
|
24
29
|
name: 'stats-plugin',
|
|
25
30
|
configResolved(config) {
|
|
26
31
|
root = config.root;
|
|
27
32
|
outDir = `${root}/${config.build.outDir}`;
|
|
28
33
|
enabled = config.env.PROD;
|
|
34
|
+
reportCompressed = config.build.reportCompressedSize;
|
|
29
35
|
},
|
|
30
36
|
resolveId: {
|
|
31
37
|
order: 'pre',
|
|
@@ -41,9 +47,9 @@ export function statsPlugin() {
|
|
|
41
47
|
if (!result) {
|
|
42
48
|
return;
|
|
43
49
|
}
|
|
44
|
-
const parent = upsertNodeIndex(stats.
|
|
45
|
-
const child = upsertNodeIndex(stats.
|
|
46
|
-
|
|
50
|
+
const parent = upsertNodeIndex(stats.moduleFileNames, truncatePath(importer));
|
|
51
|
+
const child = upsertNodeIndex(stats.moduleFileNames, truncatePath(result.id));
|
|
52
|
+
edges.add(`${parent},${child}`);
|
|
47
53
|
},
|
|
48
54
|
},
|
|
49
55
|
generateBundle: {
|
|
@@ -55,24 +61,49 @@ export function statsPlugin() {
|
|
|
55
61
|
if (chunk.type !== 'chunk') {
|
|
56
62
|
continue;
|
|
57
63
|
}
|
|
58
|
-
|
|
64
|
+
console.log(`Processing chunk "${chunk.fileName}"`);
|
|
65
|
+
const currentChunk = {
|
|
66
|
+
fileName: chunk.fileName,
|
|
67
|
+
modules: [],
|
|
68
|
+
minifiedLength: -1,
|
|
69
|
+
compressedLength: -1,
|
|
70
|
+
};
|
|
59
71
|
stats.chunks.push(currentChunk);
|
|
60
72
|
for (const [moduleName, mod] of Object.entries(chunk.modules)) {
|
|
61
73
|
const fileName = truncatePath(moduleName);
|
|
62
74
|
currentChunk.modules.push({
|
|
63
|
-
fileName,
|
|
75
|
+
fileNameIndex: upsertNodeIndex(stats.moduleFileNames, fileName),
|
|
64
76
|
renderedLength: mod.renderedLength,
|
|
65
77
|
virtual: moduleName.startsWith('\u0000') ? true : undefined,
|
|
66
78
|
});
|
|
67
79
|
}
|
|
68
80
|
}
|
|
69
|
-
|
|
81
|
+
stats.importGraph.edges = Array.from(edges).map((edge) => {
|
|
82
|
+
const pair = edge.split(',');
|
|
83
|
+
return [Number.parseInt(pair[0], 10), Number.parseInt(pair[1], 10)];
|
|
84
|
+
});
|
|
70
85
|
},
|
|
71
86
|
},
|
|
72
|
-
|
|
87
|
+
async writeBundle(_options, bundle) {
|
|
88
|
+
for (const [_name, chunk] of Object.entries(bundle)) {
|
|
89
|
+
if (chunk.type !== 'chunk') {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const c = stats.chunks.find((c) => c.fileName === chunk.fileName);
|
|
93
|
+
if (!c) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
c.minifiedLength = chunk.code.length;
|
|
97
|
+
if (reportCompressed) {
|
|
98
|
+
c.compressedLength = (await compress(chunk.code)).length;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
async closeBundle(error) {
|
|
73
103
|
if (!enabled || error) {
|
|
74
104
|
return;
|
|
75
105
|
}
|
|
106
|
+
await writeFile(join(outDir, 'stats.json'), JSON.stringify(stats));
|
|
76
107
|
console.log(`Bundle stats written to ${join(outDir, 'stats.json')}`);
|
|
77
108
|
console.log(`Run "npx vite-bundle-explorer ${join(outDir, 'stats.json')}" to view the stats`);
|
|
78
109
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--un-default-border-color, #e5e7eb)}:before,:after{--un-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.i-mdi-chart-tree{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M14 6h8v16h-8zM2 4h20V2H2zm0 4h10V6H2zm7 14h3V10H9zm-7 0h5V10H2z'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.i-mdi-graph{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M19.5 17c-.13 0-.26 0-.39.04l-1.61-3.25a2.5 2.5 0 0 0-1.75-4.29c-.13 0-.25 0-.39.04l-1.63-3.25c.48-.45.77-1.08.77-1.79a2.5 2.5 0 0 0-5 0c0 .71.29 1.34.76 1.79L8.64 9.54c-.14-.04-.26-.04-.39-.04a2.5 2.5 0 0 0-1.75 4.29l-1.61 3.25C4.76 17 4.63 17 4.5 17a2.5 2.5 0 0 0 0 5A2.5 2.5 0 0 0 7 19.5c0-.7-.29-1.34-.76-1.79l1.62-3.25c.14.04.26.04.39.04s.25 0 .39-.04l1.63 3.25c-.47.45-.77 1.09-.77 1.79a2.5 2.5 0 0 0 5 0A2.5 2.5 0 0 0 12 17c-.13 0-.26 0-.39.04L10 13.79c.46-.45.75-1.08.75-1.79s-.29-1.34-.75-1.79l1.61-3.25c.13.04.26.04.39.04s.26 0 .39-.04L14 10.21c-.45.45-.75 1.09-.75 1.79a2.5 2.5 0 0 0 2.5 2.5c.13 0 .25 0 .39-.04l1.63 3.25c-.47.45-.77 1.09-.77 1.79a2.5 2.5 0 0 0 5 0a2.5 2.5 0 0 0-2.5-2.5'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.i-mdi\:chevron-down{--un-icon:url("data:image/svg+xml;utf8,%3Csvg viewBox='0 0 24 24' width='1em' height='1em' xmlns='http://www.w3.org/2000/svg' %3E%3Cpath fill='currentColor' d='M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6z'/%3E%3C/svg%3E");-webkit-mask:var(--un-icon) no-repeat;mask:var(--un-icon) no-repeat;-webkit-mask-size:100% 100%;mask-size:100% 100%;background-color:currentColor;color:inherit;width:1em;height:1em}.relative{position:relative}.m-5{margin:1.25rem}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-auto{margin-top:auto;margin-bottom:auto}.ml-auto{margin-left:auto}.mt-2{margin-top:.5rem}.h-\[20px\]{height:20px}.h-3\.5{height:.875rem}.h-screen{height:100vh}.max-h-400px{max-height:400px}.max-w-\[350px\]{max-width:350px}.min-w-0{min-width:0}.w-\[32px\]{width:32px}.w-1\/2{width:50%}.w-1\/3{width:33.3333333333%}.w-3\.5{width:.875rem}.w-full{width:100%}.w-screen{width:100vw}.flex{display:flex}.flex-shrink-1{flex-shrink:1}.flex-grow-1{flex-grow:1}.data-\[state\=checked\]\:translate-x-full[data-state=checked]{--un-translate-x:100%;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.translate-x-0\.5{--un-translate-x:.125rem;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.group[data-state=open] .group-data-\[state\=open\]\:rotate-180{--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-rotate:180deg;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.overflow-auto{overflow:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.b,.border{border-width:1px}.border-gray-300{--un-border-opacity:1;border-color:rgb(209 213 219 / var(--un-border-opacity))}.border-indigo-700,.data-\[state\=checked\]\:border-indigo-700[data-state=checked]{--un-border-opacity:1;border-color:rgb(67 56 202 / var(--un-border-opacity))}.border-stone-300{--un-border-opacity:1;border-color:rgb(214 211 209 / var(--un-border-opacity))}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.border-none{border-style:none}.border-solid{border-style:solid}.bg-gray-200{--un-bg-opacity:1;background-color:rgb(229 231 235 / var(--un-bg-opacity))}.bg-indigo-700,.data-\[state\=checked\]\:bg-indigo-700[data-state=checked]{--un-bg-opacity:1;background-color:rgb(67 56 202 / var(--un-bg-opacity))}.bg-white{--un-bg-opacity:1;background-color:rgb(255 255 255 / var(--un-bg-opacity))}.data-\[state\=unchecked\]\:bg-stone-300[data-state=unchecked]{--un-bg-opacity:1;background-color:rgb(214 211 209 / var(--un-bg-opacity))}.hover\:bg-indigo-300:hover{--un-bg-opacity:1;background-color:rgb(165 180 252 / var(--un-bg-opacity))}.p-1{padding:.25rem}.p-2{padding:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.text-sm{font-size:.875rem;line-height:1.25rem}.c-slate-800{--un-text-opacity:1;color:rgb(30 41 59 / var(--un-text-opacity))}.c-white{--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity))}.shadow-sm{--un-shadow:var(--un-shadow-inset) 0 1px 2px 0 var(--un-shadow-color, rgb(0 0 0 / .05));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.will-change-transform{will-change:transform}
|