Open necolas opened 1 week ago
I'm happy to help advance Expo CSS extraction sitaution! Regarding the approach used by my plugin, here's the quick summary and the thinking behind the plugin:
Consistency: Reuses the project's Babel configuration by default; Bundler handles transpilation as is, while PostCSS uses the same babel config to extract CSS for the files manually specified by the globs (bypassing the need to resolve path aliases, monorepo dependencies, node_modules resolution etc).
Potential for Caching: Sharing the same Babel configuration may allow for the future possibility of reusing the Babel cache with the bundler to improve performance (cache implementation is pending). If that proves infeasible it can still maintain its own babel cache across builds
Simplified logic: Relies on Last-Modified timestamps and re-runs the process uniformly on file changes. This simplifies reasoning about the plugin's behavior and makes testing more straightforward.
Recoverability: If the plugin misses changes during watch mode due to unforeseen issues, it will re-synchronize on the next file save, ensuring the generated styles stay consistent with the source code.
Thanks, that explanation is very helpful. It looks like a pretty good approach. I'm happy to use it in the example app. Does postcss automatically get run during the Expo and Next build process?
Thanks, that explanation is very helpful. It looks like a pretty good approach. I'm happy to use it in the example app. Does postcss automatically get run during the Expo and Next build process?
Yes, both Expo and Next.js run PostCSS automatically, so the generated CSS will be bundled automatically on builds/dev.
It isn't relevant to Expo Web usage but Next.js has a known next/babel compatibility issue with App Dir so my plugin usage with Next.js is more experimental.
I'll look into configuring the example app to use my plugin and send a PR!
One thing I noticed is that it would be good if the plugin internally included the RSD package in its "include" paths array so users don't have to point to internals
Thank you very much @ecreeth @javascripter for the quick help and excellent work! I'll work on the last piece, the extra docs, and let you know when that's ready for review
One more thing I'd like to do is make the Expo example a proper Expo app, e.g., using whatever universal routing system they ship these days. We could even have a create-react-strict-dom
package that can be used to set up a working RSD/Expo project using npm create
Update the Expo SDK
We use Expo to power the example / visual regression testing app. Keeping this up-to-date is important for the following reasons:
The current challenges
Action items
postcss-react-strict-dom
.cc @ecreeth @javascripter