WordPress / wordpress-playground

Run WordPress in the browser via WebAssembly PHP
https://w.org/playground/
GNU General Public License v2.0
1.62k stars 249 forks source link

Lean WordPress build environment #167

Open adamziel opened 1 year ago

adamziel commented 1 year ago

The Gutenberg plugin development demo on Stackblitz uses the @wordpress/scripts package which requires downloading 300MB of dependencies. That's fine locally, but not so great for an in-browser environment. @gziolo and I tried to make it smaller in a few different ways:

The only remaining option seems to be recreating that build pipeline in another tool that doesn't depend on babel, core-css, and other large libraries. It may even turn into a worthwhile contribution to @wordpress/scripts. A few options:

adamziel commented 1 year ago

Here's an esbuild setup that only requires downloading 6.8M of data (compressed):

https://gist.github.com/adamziel/ab4bf95756d70c1aefd1dc56fbed2c62

adamziel commented 1 year ago

Another challenge is a leaner @php-wasm/node package – the existing one bundles all the built .wasm PHP files and requires downloading 35 MB of data (compressed). There could be a series of packages instead, like @php-wasm/node-8-0 @php-wasm/node-8-1 etc.

gziolo commented 1 year ago

Here's an esbuild setup that only requires downloading 6.8M of data (compressed):

https://gist.github.com/adamziel/ab4bf95756d70c1aefd1dc56fbed2c62

That's the best path moving forward. It probably won't be easily possible to get a 100% match with start and build commands from @wordpress/scripts, but we can try to approximate it.

danielbachhuber commented 1 year ago

There could be a series of packages instead, like @php-wasm/node-8-0 @php-wasm/node-8-1 etc.

Could we have some mechanism for “installing” different PHP versions? I imagine such an approach will become very useful if we want to support using/testing against various patch versions.

adamziel commented 1 year ago

Spot on @danielbachhuber, let's link this issue with https://github.com/WordPress/wordpress-playground/issues/58. A few options:

I'm not proposing a CDN since it's not versioned and I don't see any clear advantages over GitHub.

adamziel commented 9 months ago

WordPress Pull Request previewer is actually a WordPress build environment. The feedback loop isn't perfect as it takes 10-15 mins for GitHub actions to build the PR, but it is now possible to contribute without a local setup! This issue is now about speeding up that feedback loop.