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

Webpack updates, part 2 #95

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sdunham
Copy link
Contributor

@sdunham sdunham commented Sep 11, 2023

This is the second part of our recent webpack updates. This PR will likely require more discussion on the pros/cons of the proposed changes, as well as some refinement since we included a couple of potential paths forward which we'll need to decide between.

In summary, this PR provides a starting point for implementing proper code splitting of our JS assets, and a way to have WP enqueue the chunk files webpack creates. Currently, we rely on a single statically-named JS asset file per webpack entrypoint. This works fine, but it has some downsides:

  1. We have to handle cache-busting ourselves via a custom webpack plugin, instead of using the default method available via weboack (e.g. including a contenthash in the resulting filename).
  2. Common dependencies across entrypoints end up being duplicated between the resulting built asset files, instead of being split into chunk files that can be used by more than one entrypoint. This results in a reduced ability to cache common code and unnecessarily large bundle sizes.

We may decide to discard this functionality as something provided out of the box by Groot, and instead document it as a potential update that can be added into themes which are based on Groot if/when needed.

@sdunham sdunham requested a review from rbhensley September 11, 2023 18:47
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.

1 participant