FredKSchott / create-snowpack-app

The all-in-one app template for Snowpack. [moved]
https://www.snowpack.dev
Other
727 stars 96 forks source link

granular chunking in plugin-webpack #190

Closed mxmul closed 4 years ago

mxmul commented 4 years ago

Resolves #177.

This very closely follows the guidance from Google, and is similar to the webpack chunking strategies used by Next and Gatsby. This implementation is directly based on the reference implementation from that article: https://glitch.com/edit/#!/webpack-granular-split-chunks

The only significant difference between this config and the reference implementation is that we don't treat react, react-dom, etc... specially. In Gatsby / Next these framework libraries are pulled into a separate commons chunk, under the assumption that they'll be updated less frequently than other common modules (allowing a higher cache-hit rate across deployments). This is trickier to do as a Snowpack plugin, because we don't know which framework(s) are being used in a project. With this config, all NPM libraries are treated the same.

Note to reviewers: the first commit is a simple refactoring. It might be easier to read separately.

drwpow commented 4 years ago

Hey @mxmul! Sorry for the delay on reviewing. We’re actually in the process of archiving this project and folding it into the snowpack core repo: https://github.com/pikapkg/snowpack/tree/master/packages/%40snowpack/plugin-webpack. You wouldn’t have known this; you just happened to open up a PR right as we were migrating.

Would you mind closing this PR and opening it up on that repo? The next release for the webpack plugin will come from there. Would love to leave some feedback over there.

Edit: I should clarify I’m +1 in favor of this landing! Only closing so that we make sure this is released. Thanks for understanding.