Skip to content

Commit

Permalink
Migrate to Yarn workspaces (#146)
Browse files Browse the repository at this point in the history
This PR splits the repository into five node packages that are also yarn workspaces:

- php-cli
- php-wasm
- typescript-reference-doc-generator
- wordpress-playground
- wordpress-plugin-ide

This effectively undoes [Use folders instead of separate npm packages](#70), so you may ask "why bother?"

With this PR:

* The build process is straightforward. There's no `gulp` and there's no mountain of custom logic in `esbuild.js`. Files are moved around the repo using a simple `copy` plugin or an `import` statement. There's no custom cache busting logic – it's handled by the build tools instead
* `php-wasm` is now reusable and can be published in npm. This means it can be easily reused outside of WordPress Playground.
* Each package has its own build process that caters to its specific needs. For example, `php-cli` outputs a node.js script. Web workers can now be bundled as `iife` (which is the only way to use them in firefox) while other assets are es modules.
* There are less tasks in general. For example, TypeScript types are handled by rollup in a few packages.

At the same time, none of the [original downsides of using packages ](#70) are present:

* There's no global build pipeline. Every package outputs a complete build artifact that can be directly imported in case of libs, or used in the browser in case of the Playground website.
* Yarn workspaces ensure the tasks are executed in the correct order
* tsconfig.json and package.json can mostly be copied, there's no `api-documenter.json` at all.
  • Loading branch information
adamziel committed Mar 10, 2023
2 parents 06c8ec7 + fd7e6ce commit a7601f0
Show file tree
Hide file tree
Showing 8,236 changed files with 922,438 additions and 93,730 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
11 changes: 8 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ module.exports = {
},
extends: [
'eslint:recommended',
'plugin:@wordpress/eslint-plugin/recommended',
// 'plugin:@wordpress/eslint-plugin/recommended',
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
],
overrides: [],
// overrides: [],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
plugins: ['react'],
root: true,
plugins: ['react', '@typescript-eslint'],
rules: {
'no-inner-declarations': 0,
'no-use-before-define': 'off',
Expand All @@ -36,5 +39,7 @@ module.exports = {
'no-nested-ternary': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/no-static-element-interactions': 0,
'@typescript-eslint/ban-ts-comment': 0,
'@typescript-eslint/no-non-null-assertion': 0,
},
};
22 changes: 15 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
.DS_Store
.idea
.local
.vitepress
.vite
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
.rollup.cache
node_modules
/live-code-example
/testwp
package-lock.json
build/*
build-cli/*
build-api
build-wp
build-php
build-types
build-scripts
packages/*/build
testwp
!build/wp-admin
!build/wp-content
!build/wp-includes
Expand All @@ -18,6 +25,7 @@ build-scripts
!build/wp.data
!build/wp.js
*.tsbuildinfo
*.d.ts
tsdoc-metadata.json
var
dist.zip
Expand Down
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

873 changes: 873 additions & 0 deletions .yarn/releases/yarn-3.4.1.cjs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"

yarnPath: .yarn/releases/yarn-3.4.1.cjs
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,16 @@ You can embed WordPress Playground in your project via an `<iframe>` – find ou
You also can run WordPress Playground locally as follows:

```bash
# Install Yarn if you don't have it:
npm install -g yarn

# Now you're ready to run Playground:
git clone https://github.com/WordPress/wordpress-playground
cd wordpress-playground
npm install
npm run dev
yarn install
# An initial build is needed at the moment:
yarn run build
yarn run dev
```

A browser should open and take you to your very own client-side WordPress at [http://127.0.0.1:8777/wordpress.html](http://127.0.0.1:8777/wordpress.html)!
Expand Down
6 changes: 6 additions & 0 deletions bin/build-api-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

node packages/typescript-reference-doc-generator/build/tsdoc-to-api-markdown.js \
-e packages/php-wasm/build/web/types/index.d.ts \
packages/wordpress-plugin-ide/build/types/index.d.ts \
-o docs/api
File renamed without changes.
Empty file removed build-cli/.gitkeep
Empty file.
24 changes: 0 additions & 24 deletions build-cli/package.json

This file was deleted.

11 changes: 0 additions & 11 deletions build/.htaccess

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-5.6.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-7.0.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-7.1.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-7.2.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-7.3.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-7.4.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-8.0.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-8.1.js

This file was deleted.

5 changes: 0 additions & 5 deletions build/php-8.2.js

This file was deleted.

15 changes: 0 additions & 15 deletions build/php.node.js

This file was deleted.

351 changes: 0 additions & 351 deletions build/wp-5.9.js

This file was deleted.

Loading

0 comments on commit a7601f0

Please sign in to comment.