Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(wmr): Adding bundle visualizer #508

Merged
merged 3 commits into from
Mar 31, 2021
Merged

Conversation

rschristian
Copy link
Member

This adds a bundle visualizer behind the --visualize flag for wmr build. Visualizer plugin used: https://github.com/btd/rollup-plugin-visualizer

When ran, a stats.html file will be created in the root of the project and the file will be opened in the users' default user agent. They'll get a tree graph that will show the break down of their app rendered as well as with brotli and gzip.

Seems like the most popular visualizer for Rollup, and is on Vite's roadmap of plugins to cover. This does increase the bundle as a bit as the template JS is ~82kb (mostly) unminified

@changeset-bot
Copy link

changeset-bot bot commented Mar 31, 2021

🦋 Changeset detected

Latest commit: 89b402e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wmr Minor
create-wmr Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 31, 2021

Size Change: +37.6 kB (+5%) 🔍

Total Size: 733 kB

Filename Size Change
packages/wmr/wmr.cjs 699 kB +37.6 kB (+6%) 🔍
ℹ️ View Unchanged
Filename Size Change
examples/demo/dist/about/index.html 667 B 0 B
examples/demo/dist/assets/Calendar.********.css 702 B 0 B
examples/demo/dist/assets/style.********.css 386 B 0 B
examples/demo/dist/chunks/class-fields.********.js 200 B 0 B
examples/demo/dist/chunks/compat.********.js 15.3 kB 0 B
examples/demo/dist/chunks/index.********.js 199 B 0 B
examples/demo/dist/chunks/json.********.js 235 B 0 B
examples/demo/dist/chunks/prerender.********.js 2.41 kB 0 B
examples/demo/dist/class-fields/index.html 646 B 0 B
examples/demo/dist/compat/index.html 1.5 kB 0 B
examples/demo/dist/env/index.html 722 B 0 B
examples/demo/dist/error/index.html 656 B 0 B
examples/demo/dist/files/index.html 688 B 0 B
examples/demo/dist/index.********.js 7.23 kB 0 B
examples/demo/dist/index.html 714 B 0 B
examples/demo/dist/json/index.html 666 B 0 B
examples/demo/dist/lazy-and-late/index.html 668 B 0 B

compressed-size-action

Comment on lines +119 to +127
/fs\.readFile\(path\.join\(__dirname,\s*(.+?)\)\s*,\s*"utf8"\s*\)/g,
(str, stringifiedJoin) => {
const path = require('path');
const fs = require('fs');
const filePathParts = stringifiedJoin
.replace(/['"`]+/g, '')
.replace(/\$\{template\}/g, 'treemap')
.split(', ');
const filepath = path.resolve(path.dirname(id), ...filePathParts);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For simplicity's sake when reviewing, these are the lines that need to be replaced: https://github.com/btd/rollup-plugin-visualizer/blob/799b5337db4fbbf8b83119b6251efe9e33c0ab69/plugin/build-stats.js#L58-L59

The template is a visualizer format, i.e., treemap, sunburst, or network. Treemap seems to be the most common so I just went with that.

@danielweck
Copy link

Well, that's interesting / timely :)
The other day I integrated rollup-plugin-size-snapshot ( https://github.com/TrySound/rollup-plugin-size-snapshot ) and rollup-plugin-analyzer ( https://github.com/doesdev/rollup-plugin-analyzer ) in my build, but the generated stats were not very useful so I aborted (not the plugins' fault, more to do with the WMR's plugin sequence I think).
I look forward to trying this PR!

Copy link
Member

@JoviDeCroock JoviDeCroock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome :shipit:

@danielweck
Copy link

danielweck commented Mar 31, 2021

Tested. Seems to represent my pre-rendered JS bundles / chunks accurately. Thank you!

Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great 👍

@marvinhagemeister marvinhagemeister merged commit 81750d6 into main Mar 31, 2021
@marvinhagemeister marvinhagemeister deleted the feat/bundle-visualizer branch March 31, 2021 11:11
@github-actions github-actions bot mentioned this pull request Mar 31, 2021
Copy link
Member

@developit developit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants