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

Build: Add support for Webpack bundle analyzer #10185

Merged
merged 3 commits into from
Oct 15, 2018

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented Sep 26, 2018

Description

This PR enabled support for Webpack bundle analyzer hidden behind the environment flag BUNDLE_ANALYZER.

We still need to document this and other env flags we use in the Webpack config.

How has this been tested?

BUNDLE_ANALYZER=1 npm run dev

Screenshots

screen shot 2018-09-26 at 10 48 37

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@gziolo gziolo added the [Type] Build Tooling Issues or PRs related to build tooling label Sep 26, 2018
@gziolo gziolo self-assigned this Sep 26, 2018
@gziolo
Copy link
Member Author

gziolo commented Sep 26, 2018

Open question is if we want to standardize the name of flags offered inside Webpack config. We have the following:

  • BUNDLE_ANALYZER
  • SOURCEMAP
  • GUTENBERG_LIVE_RELOAD_PORT

Should we prefix all of them with GUTENBERG_ or skip it at all?

Where should we put the documentation? We still need to provide missing docs for the source map and live-reload feature.

@atimmer
Copy link
Member

atimmer commented Sep 26, 2018

Ooh, I like solving toggling it on and off using environment variables. I am going to copy this for our plugins if you don't mind. I like it!

Copy link
Member

@atimmer atimmer left a comment

Choose a reason for hiding this comment

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

Prefixing them with something (in this case GUTENBERG_) is a good idea, because that allows them to be set globally in your environment and not conflict with other environment variables. So if I wanted to always run the live reload on a different port I could set that environment variable in my shell startup file.

The only disadvantage is typing a bit more when running it inline PREFIX_BUNDLE_ANALYZER=1 npm run dev.

@gziolo
Copy link
Member Author

gziolo commented Sep 26, 2018

Ooh, I like solving toggling it on and off using environment variables. I am going to copy this for our plugins if you don't mind. I like it!

Sure things, not that I come up with it myself. Calypso has this plugin enabled for long. I just wanted to enable another tool which would help to check if we don't introduce huge deps when bringing in external libraries :)

@noisysocks
Copy link
Member

Should we prefix all of them with GUTENBERG_ or skip it at all?

I think prefixing with GUTENBERG_ or WP_ is a good idea for consistency and so that they don't conflict with other environments like @atimmer says.

Wondering also if we should rename SOURCEMAP to SOURCE_MAP or even DEVTOOL for consistency with what the actual Webpack property is.

Where should we put the documentation? We still need to provide missing docs for the source map and live-reload feature.

Not too sure about this. CONTRIBUTING.md is the only place where we touch on build tooling at the moment. Maybe a new Build Tooling section in the handbook underneath Reference is warranted.

@gziolo gziolo added this to the 4.1 milestone Oct 11, 2018
@gziolo gziolo requested a review from a team October 11, 2018 13:38
@gziolo gziolo force-pushed the add/webpack-bundle-analyzer branch from 224223b to fc8b079 Compare October 11, 2018 13:42
@gziolo gziolo force-pushed the add/webpack-bundle-analyzer branch from fc8b079 to 61bceee Compare October 11, 2018 13:43
@gziolo
Copy link
Member Author

gziolo commented Oct 11, 2018

I added prefix GUTENBERG_ to all global variables used in Webpack's config. I also included inline comments to better explain what purpose they play.

We have #8982 files to document how Webpack works, so I will leave a more detailed task to be included there. See #8982 (comment).

@gziolo gziolo requested a review from atimmer October 11, 2018 15:09
@gziolo gziolo force-pushed the add/webpack-bundle-analyzer branch from 91da5ce to 342b1fa Compare October 11, 2018 15:11
@gziolo gziolo requested a review from ntwb October 12, 2018 07:39
@gziolo gziolo dismissed atimmer’s stale review October 13, 2018 06:41

Comments addressed

@gziolo gziolo merged commit 36e2c84 into master Oct 15, 2018
@gziolo gziolo deleted the add/webpack-bundle-analyzer branch October 15, 2018 06:44
@aduth aduth mentioned this pull request Apr 24, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Build Tooling Issues or PRs related to build tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants