Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepo #57

Merged
merged 12 commits into from
Oct 22, 2022
Merged

Monorepo #57

merged 12 commits into from
Oct 22, 2022

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Oct 21, 2022

Restructures the repository as a monorepo and separates the PHP implementation from the WordPress-specific bits.

Notably, this PR removes node.js-specific WordPress setup to help focus on the browser version. Building PHP to WASM with node.js as a target is still supported, but the express.js server and wp-specific logic is gone. Why? There's no good use-case to justify the effort of maintaining it. If one arises, I'm more than happy to bring it back, probably as a separate package.

The new packages:

  • php-wasm – low-level WASM PHP primitives
    • A configurable PHP build pipeline for different targets (web, node.js)
    • 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 to remove them from the repo entirely. In the latter case the initial build would download them from somewhere to avoid bad developer experience of having to go through a full build before even getting started.
  • 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

@adamziel adamziel force-pushed the separate-php-from-wp branch from 21fdadb to 8c30a1c Compare October 22, 2022 00:02
@adamziel adamziel force-pushed the separate-php-from-wp branch from 8c30a1c to c3edcda Compare October 22, 2022 00:04
@adamziel adamziel changed the title [wip] Separate PHP from WordPress Monorepo Oct 22, 2022
@adamziel adamziel self-assigned this Oct 22, 2022
@adamziel adamziel marked this pull request as ready for review October 22, 2022 00:27
@adamziel
Copy link
Collaborator Author

adamziel commented Oct 22, 2022

There are some rough edges, but it's a good start so I'll go ahead and merge.

@adamziel adamziel merged commit e45cbf1 into trunk Oct 22, 2022
@adamziel adamziel deleted the separate-php-from-wp branch October 22, 2022 00:36
@adamziel
Copy link
Collaborator Author

Follow-up issue: #58

adamziel added a commit that referenced this pull request Nov 7, 2022
This PR populates /docs with a step-by-step documentation connecting the priors documentation efforts shipped in:

* API Reference documentation #63
* Migrate the project to TypeScript #61
* Add developer documentation  #60
* Monorepo #57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant