WordPress / wordpress-wasm
- среда, 28 сентября 2022 г. в 00:35:42
Run WordPress in the browser thanks to WebAssembly magic
See the WordPress.org blog post explaining why is this useful and how does it work for more details. The README doc below is short&sweet for now. Also, explore the early preview on StackBlitz.
This repository ships with a pre-built demo that you can just run!
npm install && npm run dev
If you want to build the assembly yourself, follow the instructions below.
This repo draws inspiration from https://github.com/seanmorris/php-wasm and uses https://github.com/aaemnnosttv/wp-sqlite-db
The build process is split into automated parts. The scripts below create a docker image with the necessary tools, and build PHP as WebAssembly.
npm run build:php:web
npm run build:php:node
If you'd like to customize the packaged WordPress installation, study and update the build scripts accordingly.
This repo uses four magic ingredients to make WordPress work in the browser:
The static files (.js, .css, etc.) are served directly from the host filesystem, not from the WebAssembly bundle.
The work is heavily inspired by https://github.com/seanmorris/php-wasm.
The worker applies a series of strange patches to WordPress, it's unclear why they're needed at the moment.
The site editor does not work at the moment. The block editor does, though.
PHP cannot communicate with WordPress.org so the plugin directory etc does not work.
The sqlite database lives in the memory and the changes only live as long as the service worker.