Improvements to the build development workflow #36142
Replies: 4 comments 1 reply
-
I didn't think this was possible due to how we have it set up where each package is loaded into WordPress as a seperate dependency e.g. |
Beta Was this translation helpful? Give feedback.
-
Hmm, not sure what you mean here. What we're currently doing is roughly this:
Instead, I propose we skip (1) and (2) entirely, and just use webpack and |
Beta Was this translation helpful? Give feedback.
-
To be able to use SWC or esbuild, we need to remove all custom Babel plugins first. The most important one would be to stop using our custom plugins for JSX transforms as proposed in #34221. |
Beta Was this translation helpful? Give feedback.
-
There are a few ongoing explorations that are worth emphasizing in this discussion:
Some of the topics from the list were discussed during the bi-weekly Core JS meeting on WordPress Slack (link requires registration at https://make.wordpress.org/chat): https://wordpress.slack.com/archives/C5UNMSU4R/p1639494096224000 We agreed to continue explorations as follows:
|
Beta Was this translation helpful? Give feedback.
-
It's just a curated list that's been sitting in my head for too long and it's growing bigger and bigger. I just want to list them down here for visibility and to hopefully gather some feedbacks.
Note that these improvements should only affect
development
mode, so that the production builds stay intact. While some of these sound like breaking changes, we can add some feature flags or environment variables to require the developers to opt-in to them.The current development workflow (
npm run dev
) consists of roughly 2 parts: building the packages with Babel and bundling them with webpack. This 2-pass workflow isn't really efficient, we're essentially starting 2 watchers on our file system and writing double the code to disk. Instead, we can leverage webpack to do all these in a single pass in development mode so that the initial startup could be faster.This just seems like a low-hanging fruit we can do to just drop replace babel with SWC to decrease the build time. Note that we'd probably lose some features that the custom babel plugins provide, so we have to handle them gracefully.
IO read/write is quite expensive, we can instead writing them to memory to improve the performance. A bonus advantage is that there's no longer a stale build, since that whenever we change the files the build will be invalidated and recompiled.
React has official support of React Fast Refresh, while webpack can also offer CSS hot reload. This should dramatically improve our DX with a faster feedback cycle for simple changes like adjusting styles.
Thoughts? Prior arts we can take experience from? More ideas?
Hit the thumbs-up button and subscribe to this issue for more interesting ideas in the future 😜 .
Beta Was this translation helpful? Give feedback.
All reactions