You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You will find 2/3 files in .svelte-kit/output dir named stats.html (see vite logs for file locations) . You can use this snippet as a starting point and change props/path.
96
-
You can also generate 3 json files and combine them to one with cli util.
97
-
98
-
## How to use generated files
99
-
100
-
Blue color used to to mark project-own files. This could be: written by you files or generated by build tool files.
101
+
SvelteKit may run Vite multiple times, so you can get 2-3 generated files in `.svelte-kit/output` (check Vite logs for exact locations).
102
+
You can also generate raw JSON reports and merge them with the CLI.
101
103
102
-
Green color used to mark your dependencies.
104
+
## Understanding The Report
103
105
104
-
Internally it just checks if file id prefix is `node_modules`.
105
-
106
-
All charts refresh layout on window resize.
106
+
- Blue marks project files (including files generated by your build tool).
107
+
- Green marks dependencies.
108
+
- This is determined by whether a file path starts with `node_modules`.
109
+
- All chart layouts refresh when the window is resized.
107
110
108
111
### Sunburst
109
112
110
-
This circular hierarchical diagram can help you find huge pieces of code (aka that one huge thing). If you click on some arc it will increase its and all nested arcs size for better inspection.
113
+
The circular view is useful for spotting large chunks of code. Clicking an arc zooms into that section and enlarges nested arcs for inspection.
111
114
112
115
### Flamegraph
113
116
114
-
This diagram is top down version of sunburst. It is used a lot by other JS developer tools and would be very familar to developers.
117
+
This is a top-down version of the sunburst view and should feel familiar if you use other JavaScript performance tooling.
115
118
116
119
### Treemap
117
120
118
-
This rectangular hierarchical diagram can help you find huge pieces. Just look on biggest rectangle. But also it can help you find modules included several times, they will have the same topology and relative size. If you click on rectangle it will increase in size for further inspection.
121
+
This rectangular hierarchical view makes large modules easy to find quickly. It can also reveal repeated modules, because repeated content tends to show similar structure and relative size.
119
122
120
123
### Network
121
124
122
-
This diagram should help you answer for the question 'why it is included?'. After force layout stabilize all nodes, you can move it back and forth by dragging with your mouse. Gray circles are treeshaken out files.
125
+
Use this view to answer, "Why is this included?"
126
+
After the force layout stabilizes, you can drag nodes around. Gray circles are tree-shaken files.
127
+
128
+
In real projects, network graphs can look noisy. A practical way to explore them is:
123
129
124
-
In real life scenarios, sometimes you will see terribly connected diagrams. There is no 100% working solution for everyone, it is expected you topology will look 'terrible' and not hold on screen. To make it still visually inspectable, first remove all highly connected nodes that you see (typical examples: commonjsHelpers, tslib, react etc, basically if tooltip for the node is not hold on the screen - exclude this node), after layout stabilization you will see, your layout is not that terrible anymore and most of dependencies cluster together. Move layout to find pieces you looked for.
130
+
1. Remove highly connected helper nodes (for example `commonjsHelpers`, `tslib`, `react`) when they dominate the graph.
131
+
2. Wait for layout stabilization.
132
+
3. Explore clusters that become easier to read.
125
133
126
-
When you click on node it will highlight nodes that are listed in tooltip (the files that imports current node).
134
+
Clicking a node highlights nodes listed in its tooltip (the files that import that node).
127
135
128
136
### Raw-data
129
137
130
-
This template produce JSON output with raw data. Normally it should be used with CLI from this plugin.
138
+
Produces JSON output with raw data. Usually used together with the CLI.
131
139
132
140
### List
133
141
134
-
Output yml file with all the data, could be good idea to commit this file to track file changes.
142
+
Produces a YAML file with report data. This is useful to commit and track bundle changes over time.
135
143
136
144
### Markdown
137
145
138
-
Output markdown report with summary tables and bottom notes about report config and size precision.
146
+
Produces a Markdown report with summary tables and notes about config and size precision.
139
147
140
148
## Options
141
149
142
-
`filename` (string, default `stats.{ext depending template}`) - name of the file with diagram to generate
143
-
144
-
`title` (string, default `Rollup Visualizer`) - title tag value
145
-
146
-
`open` (boolean, default `false`) - Open generated file in default user agent
147
-
148
-
`template` (string, default `treemap`) - Which diagram type to use: `sunburst`, `treemap`, `network`, `raw-data`, `list`, `markdown`, `flamegraph`.
149
-
150
-
`gzipSize` (boolean, default `false`) - Collect gzip size from source code and display it at chart.
151
-
152
-
`brotliSize` (boolean, default `false`) - Collect brotli size from source code and display it at chart.
150
+
-`filename` (`string`, default `stats.{ext based on template}`): Name of the generated report file.
151
+
-`title` (`string`, default `Rollup Visualizer`): HTML `<title>` value.
152
+
-`open` (`boolean`, default `false`): Open the generated file in your default browser.
-`gzipSize` (`boolean`, default `false`): Include gzip size in the report.
155
+
-`brotliSize` (`boolean`, default `false`): Include Brotli size in the report.
153
156
154
-
### Advanced options (touch only if you really need it):
157
+
### Advanced options (only if needed)
155
158
156
-
`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 useful with svelte as it calls vite several times.
159
+
-`emitFile` (`boolean`, default `false`): Use Rollup `emitFile` to generate output. Useful when you want all assets managed by Rollup output settings. Also helpful for SvelteKit multi-build runs. When this is `true`, `filename` must be a file name, not a path.
160
+
-`sourcemap` (`boolean`, default `false`): Use source maps for module size calculations (for example after Terser/UglifyJS). Keep this plugin last.
161
+
-`projectRoot` (`string | RegExp`, default `process.cwd()`): Common root path used to trim absolute file paths in reports.
162
+
-`include` (`Filter | Filter[]`, default `undefined`): Include filter.
`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.
167
+
**Note on `include` and `exclude`**:
168
+
If `include` is omitted or empty, files are included by default.
169
+
Otherwise, an ID must match at least one `include` pattern and must not match any `exclude` pattern.
161
170
162
-
`include` (Filter | Filter[], default `undefined`) - Filter for inclusion
171
+
### Include And Exclude
163
172
164
-
`exclude` (Filter | Filter[], default `undefined`) - Filter for exclusion
173
+
Filters use picomatch globs, and support these forms:
165
174
166
-
`Filter` type is `{ bundle?: picomatchPattern, file?: picomatchPattern }`
175
+
- Bundle + file in one string: `translation-*.js:*/**/index.js`
176
+
- Bundle only: `translation-*.js:`
177
+
- File only (default): `*/**/index.js`
167
178
168
-
**Note about `include` and `exclude`** - If options.include is omitted or has zero length, filter will return true by default. Otherwise, an ID must match one or more of the picomatch patterns, and must not match any of the options.exclude patterns. This entries will not be included in stats at all.
169
-
170
-
#### Include and Exclude
171
-
172
-
Include and exclude filters uses glob matchers with picomatch. In UI you can do such combinations (both exclude and include):
173
-
174
-
- Filter bundle and file in one string
175
-
-`translation-*.js:*/**/index.js` - this selects all bundles that matches `translation-*.js` and all the files by all paths that name is `index.js`. `:` is separator and required only when bundle search used.
176
-
- Format for this kind of filter is `BUNDLE_GLOB:FILE_GLOB`
177
-
- Filter bundle in one string
178
-
- This is special case of bundle+file filter, you need to omit `FILE_GLOB` part (empty string)
179
-
- Filter file in one string
180
-
-**This is DEFAULT search option**
181
-
-`*/**/index.js` - select all files that name is index.js
179
+
Format: `BUNDLE_GLOB:FILE_GLOB` (`:` is required when bundle matching is used).
182
180
183
181
## CLI
184
182
185
-
This plugin provides cli util `rollup-plugin-visualizer`. Add `--help` to check actual options. It can be used like:
183
+
This package provides a CLI utility: `rollup-plugin-visualizer`.
This can be useful in case you have different config files in the same project and you want to display all of them in the same chart.
191
+
This is useful when you have multiple build configs and want to combine reports into one chart.
192
192
193
193
## Build plugin
194
194
195
-
For development if you need to build plugin, just exec:
195
+
For local development:
196
196
197
-
```js
197
+
```sh
198
198
npm run build
199
199
```
200
200
201
201
## Disclaimer about generated files
202
202
203
-
Generated html files do not and never will contain your source code (contents of files). They can contain only js/html/css code required to build chart (plugin code) and statistical information about your source code.
203
+
Generated HTML files do not include your source code contents.
204
+
They only include:
205
+
206
+
- JS/HTML/CSS required for the chart UI
207
+
- Statistical metadata about your code
204
208
205
-
This statistical information can contain:
209
+
This metadata can include:
206
210
207
-
-size of files included in bundle
208
-
-size of files included in source map
209
-
-file's paths
210
-
-files hierarchy (fs tree for your files)
211
+
-Sizes of files in the bundle
212
+
-Sizes of files in source maps
213
+
-File paths
214
+
-File hierarchy
211
215
212
216
## Upgrades
213
217
214
-
See CHANGELOG.md.
218
+
See `CHANGELOG.md`.
215
219
216
220
## Versioning
217
221
218
-
-Plugin backend (one appears in configs) are strictly follows SemVer
219
-
- Plugin frontend (generated file):
220
-
-`network`, `treemap`, `sunburst`, `flamegraph` can change does not matter of version (colors, texts, visual structure etc)
221
-
-`raw-data` format follows own `version` property
222
-
-`list`and `markdown` follows semver
222
+
-The plugin API (the part used in your build config) follows SemVer.
223
+
- Frontend report templates can change visual details (`network`, `treemap`, `sunburst`, `flamegraph`) without strict SemVer guarantees.
224
+
-`raw-data` uses its own `version` field.
225
+
-`list` output follows SemVer.
226
+
-`markdown` output is experimental and does not follow strict versioning. It will evolve with LLM capabilities.
0 commit comments