-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CSS + code splitting + multiple entry points #608
Comments
My working plan so far is to generate CSS |
Following, I would love to ditch webpack and those long long wait times per build, but we need CSS as a valid entrypoint to do that. |
As a workaround for the time being, one way to use code splitting and CSS is to build twice:
You can also output these two builds in two location and do them concurrently which is neat. |
@evanw I'd love to help out with this if possible - but a little lost as to how to get started. We're currently using the workaround @michaelvillar suggested currently but isn't scaling as we build more applications at once. |
The best way to help at this point would be to help me figure out the desired behavior. I'm not too familiar with the history and design space here or how other bundlers solve CSS ordering problems. CSS is order-dependent and I assume CSS order should be determined by a depth-first post-order traversal over the graph, including from JS files into the CSS files they import (ignoring top-level await). I also assume that it's not ok for the bundler to deviate from this order at all since that could result in visual changes, even if deviating from this order would make a smaller bundle. Some approaches to CSS code splitting that I can imagine:
I'm currently considering doing option 1 (no code splitting for CSS). |
I ended up landing on a workaround for the time being similar to another comment on the MVP for CSS modules. I'll share the plugin I wrote shortly but it's on my work laptop and I can't extract it right now. Essentially I would go with something like (3) from above, but use the The only issue that I don't have an answer for with this is preventing the everlasting issue of flashes of unstyled content, since the stylesheets are loaded asynchronously to the execution of the app. I'm not sure how other bundles are solving this at the moment though. |
I think Webpack goes with option 1 (disregard dynamic chunks as far as css output is concerned), which seems to be the most straightforward approach (and can be incrementally improved if needed). Plus it's probably what everyone would already imagine when reading "There is currently no support for code splitting of CSS" - the current behaviour is quite confusing. |
🥳 |
Background
Hey! Per the changelog, ESBuild doesn’t currently support code splitting with CSS:
Still, a) enabling
splitting: true
along with b) importing CSS files and c) having multiple entry points results in the following behavior:chunk.HASH.css
)Which means that when you open the app, the common CSS code ends up simply missing.
Question
I’m curious what’s your plan on supporting this scenario.
@import
s for code-split CSS chunks?I’m asking this primarily because I’m helping Framer to migrate to ESBuild, and if I know the plan, it would be easier to pick the right workaround while the plan is being implemented!
The text was updated successfully, but these errors were encountered: