Skip to content

Commit e45cbf1

Browse files
authored
Monorepo (#57)
Restructures the repository as monorepo and separates the PHP implementation from the WordPress-specific bits. The new packages: * **php-wasm** – low-level WASM PHP primitives * A configurable PHP build pipeline for different targets (web, node.js, standalone) * A low-level `PHP` JavaScript class with `eval` for executing PHP code and FS utils like `writeFile` for runtime managing the * A `PHPServer` JavaScript class for dispatching HTTP requests – both to run the PHP files AND to download static files * A `PHPBrowser` JavaScript class to consume the above using an iframe * **php-wasm-browser** – a high-level layer to efficiently run `php-wasm` in the browser * `service-worker` utilities to redirect the browser traffic to `PHPServer` * `worker-thread` utilities to offload the `PHPServer` to a separate process. Three backends are available: Iframe, Webworker, SharedWorker. * A messaging layer and setup helpers to connect the above. * Server utilities to serve the correct headers for the `wasm` files via `.htaccess`. * **wordpress-wasm** – WordPress-specific WASM PHP bindings for web and node.js * The required WordPress-specific setup like constants and filters * `wp.data` bundling pipeline for the web configurable to bundle custom code * WordPress API to ease common tasks like login, install a plugin, start a block editor with specific settings and content * A `fetch`-based transport for HTTP requests * An example app demonstrating WordPress in the browser. Let's eventually extract it into a separate package or at least a directory. Other, general notes: * Pre-built binaries are shipped in the global `build` directory – it would be nice to either move them to their specific packages, or remove them from the repo completely and download them from somewhere on the initial build. * `esbuild` is used to build each packages and then the entire app. * Gulp is used for orchestration. Perhaps https://nx.dev/ would make a good replacement in the future. * There is no package publishing process yet. Perhaps Lerna would make a good one? Solves #51 and #16
1 parent 228ccc3 commit e45cbf1

File tree

7,570 files changed

+6870
-1591834
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

7,570 files changed

+6870
-1591834
lines changed

.eslintignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
node_modules/**/*
2-
wasm-build/**/*
3-
dist-web/**/*
4-
dist-node/**/*
5-
src/node/wordpress/**/*
6-
node-php.js
2+
build/*
3+
packages/*/build*/*

.gitignore

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
.DS_Store
22
.idea
3+
.local
34
node_modules
45
package-lock.json
5-
wasm-build/php/docker-output/*
6-
!wasm-build/php/docker-output/.gitkeep
7-
wasm-build/wordpress-data/docker-output/*
8-
!wasm-build/wordpress-data/docker-output/.gitkeep
9-
wasm-build/wordpress-data/preload/wordpress*
10-
dist-web/wp-lazy-files.js
11-
dist-web/service-worker.js
12-
dist-web/wasm-worker.js
13-
dist-web/app.js
14-
dist-web/*.html
15-
dist-web/wp-lazy-files.js
16-
6+
build/*
7+
!build/wp-admin
8+
!build/wp-content
9+
!build/wp-includes
10+
!build/php.wasm
11+
!build/php-web.js
12+
!build/php-webworker.js
13+
!build/wp.data
14+
!build/wp.js
15+
packages/*/build*
16+
packages/*/build*/*

.prettierignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
node_modules/**/*
2-
wasm-build/**/*
3-
dist-web/**/*
4-
dist-node/**/*
5-
src/node/wordpress/**/*
6-
node-php.js
2+
build/*
3+
packages/*/build*/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ npm run build:php:node
3636
## Building custom WordPress bundle
3737

3838
If you'd like to customize the packaged WordPress installation, update
39-
the build script at `wasm-build/wordpress-data/prepare-wordpress.sh`. It generates a bundle called `wp.data`.
39+
the build script at `packages/wordpress-wasm/wordpress/prepare-wordpress.sh`. It generates a bundle called `wp.data`.
4040

4141
For example, before the comment "Prepare WordPress static files":
4242

build.js

Lines changed: 0 additions & 158 deletions
This file was deleted.

build/.htaccess

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
AddType application/wasm .wasm
2+
3+
RewriteEngine on
4+
RewriteRule ^scope:.*?/(.*)$ $1 [NC]
5+
6+
<FilesMatch "iframe-worker.html$">
7+
Header set Origin-Agent-Cluster: ?1
8+
</FilesMatch>
9+
10+
RewriteEngine on
11+
RewriteRule ^plugin-proxy$ plugin-proxy.php [NC]

build/php-web.js

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/php-webworker.js

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/php.wasm

5.38 MB
Binary file not shown.

0 commit comments

Comments
 (0)