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

Dev - Bundles Contain Duplicate Code #877

Closed
pastelsky opened this issue Feb 12, 2017 · 9 comments
Closed

Dev - Bundles Contain Duplicate Code #877

pastelsky opened this issue Feb 12, 2017 · 9 comments

Comments

@pastelsky
Copy link
Collaborator

pastelsky commented Feb 12, 2017

The output of npm run build generates a bunch of .js split points, and each of them seem to have a copy of preact and other npm libs.

I tried introducing CommonsChunkPlugin in webpack.config, but don't find any commons file being generated. This is pretty inefficient and perhaps loading a single commons bundle upfront would be better.

@bebraw Any clue if this config comes from antwar side of things?

@bebraw
Copy link
Contributor

bebraw commented Feb 12, 2017

It generates a build per each page (the interactive bits). To fix this, you would have to dig into Antwar around here. PRs welcome. 👍

@bebraw
Copy link
Contributor

bebraw commented Feb 13, 2017

I think I know how to handle this now. Basically the interactive build has to treat preact/preact-dom as externals (cuts most of the size). preact/preact-dom have to be bundled separately by the main config and then wired to the template (HtmlWebpackPlugin might do this automatically). That would solve it.

@pastelsky
Copy link
Collaborator Author

pastelsky commented Feb 13, 2017

Great. However it's not just preact. > 95% of the code between these split points is the same. The only thing that differs is the rendering of the items in the sidebar and top nav depending on route.
Do we need split points here at all? Looks like it could be tucked into a single bundle.

@bebraw
Copy link
Contributor

bebraw commented Feb 13, 2017

That would need a different approach entirely.

@pastelsky
Copy link
Collaborator Author

pastelsky commented Feb 13, 2017 via email

@skipjack
Copy link
Collaborator

@bebraw is this something specific to this site, or more just related to how antwar's <Interactive> component behaves? If it's not specific to this site maybe we can close and push to this issue over to the antwarjs repo (unless you are saying this is already a "won't fix")?

@bebraw
Copy link
Contributor

bebraw commented May 11, 2017

@skipjack It's a difficult one to fix but we can leave this open for now. I have a feeling treating Preact and its dependencies as externals at webpack configuration would solve most of this.

@TheLarkInn
Copy link
Member

I'm definitely interested in converting docs into a PWA, so keep me looped in or tagged if this ends up in another issue.

@skipjack skipjack changed the title Javascript bundles in webpack.js.org contain duplicate code Dev - Bundles Contain Duplicate Code Jun 14, 2017
@skipjack
Copy link
Collaborator

skipjack commented Jul 6, 2017

Closing in favor of #1380 -- I think a port or major antwar update like #980 may address this.

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

No branches or pull requests

4 participants