Skip to content

Commit 57d3b59

Browse files
committed
Migrate to NX-based build (#151)
## Description Sets up the correct build pipeline for all parts of Playground and PHP.wasm. This enables a public release of the [Playground API](WordPress/wordpress-playground#149) npm package! I've been [struggling](WordPress/wordpress-playground#146) with [this](WordPress/wordpress-playground#70) for [a while](WordPress/wordpress-playground#150) and couldn't understand what's so hard. NX made it apparent – look at this dependency graph! <img width="1291" alt="CleanShot 2023-03-16 at 23 16 26@2x" src="https://user-images.githubusercontent.com/205419/225764795-7fa8e972-09f8-41ef-aac2-1c96bd100ea0.png"> No wonder it's been almost impossible to set everything up by hand! ## Usage Start with `yarn install` ### Shortcuts To start a copy of `wasm.wordpress.net` locally, run `yarn run dev`. To build it, run `yarn run build`. ### Fully qualified commands In reality, these `yarn run` commands are just triggering the underlying project's nx `dev` and `build` commands: ```bash nx dev playground-website nx build playground-website ``` Here's a few more interesting commands: ```bash # Build and run PHP.wasm CLI nx start php-wasm-cli # Build latest WordPress releases nx recompile-wordpress:all playground-remote # Recompile PHP 5.6 - 8.2 releases to .wasm for web nx recompile-php:all php-wasm-web # Recompile PHP 5.6 - 8.2 releases to .wasm for node nx recompile-php:all php-wasm-node # Builds markdown files for readthedocs site nx build docs-site # Builds the Playground Client npm package nx build playground-client ``` ## NX is the tool Playground needed from the outset It's ridiculous how many problems this solves: * The build pipeline is explicitly defined and easy to modify * Tasks only run once their dependencies are ready * The dev mode works and is fast * The build works and is fast * We get CI checks to confirm the entire build process still works (which solves #150) * Cross-package TypeScript just works * There are linters and formatters (which solves #14) * Documentation is correctly generated from the latest built artifacts * There are nice generators for bootstraping new packages and moving the existing ones around * There are checks to ensure the private `php-wasm-common` package is not imported by anything else than `php-wasm-web` and `php-wasm-node` ## Next steps * Add Lerna to harness package publishing * Additional developer documentation for the nx-based flow Related to WordPress/wordpress-playground#148 and WordPress/wordpress-playground#147
1 parent 4edf319 commit 57d3b59

File tree

1,069 files changed

+93064
-102107
lines changed

Some content is hidden

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

1,069 files changed

+93064
-102107
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
max_line_length = off
13+
trim_trailing_whitespace = false

.eslintignore

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
node_modules/**/*
2-
build/*
3-
packages/*/build*/*
4-
src/php-wasm/wasm/build-assets/*
1+
node_modules
2+
packages/php-wasm/node/public
3+
packages/php-wasm/web/public
4+
packages/php-wasm/compile/build-assets
5+
packages/playground/compile-wordpress/build-assets
6+
__pycache__
7+
packages/playground/remote/src/wordpress
8+
*.timestamp-1678999213403.mjs
9+
.local
10+
.vscode

.eslintrc.js

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

.eslintrc.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"root": true,
3+
"ignorePatterns": ["**/*"],
4+
"plugins": ["@nrwl/nx"],
5+
"overrides": [
6+
{
7+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
8+
"rules": {
9+
"@nrwl/nx/enforce-module-boundaries": [
10+
"error",
11+
{
12+
"enforceBuildableLibDependency": true,
13+
"allow": [],
14+
"depConstraints": []
15+
}
16+
],
17+
"no-inner-declarations": 0,
18+
"no-use-before-define": "off",
19+
"react/prop-types": 0,
20+
"no-console": 0,
21+
"no-empty": 0,
22+
"no-async-promise-executor": 0,
23+
"no-constant-condition": 0,
24+
"no-nested-ternary": 0,
25+
"jsx-a11y/click-events-have-key-events": 0,
26+
"jsx-a11y/no-static-element-interactions": 0
27+
}
28+
},
29+
{
30+
"files": ["*.ts", "*.tsx"],
31+
"extends": ["plugin:@nrwl/nx/typescript"],
32+
"rules": {
33+
"@typescript-eslint/ban-ts-comment": 0,
34+
"@typescript-eslint/ban-types": 0,
35+
"@typescript-eslint/no-non-null-assertion": 0,
36+
"@typescript-eslint/no-explicit-any": 0,
37+
"no-constant-condition": 0
38+
}
39+
},
40+
{
41+
"files": ["*.js", "*.jsx"],
42+
"extends": ["plugin:@nrwl/nx/javascript"],
43+
"rules": {}
44+
},
45+
{
46+
"files": "*.json",
47+
"parser": "jsonc-eslint-parser",
48+
"rules": {}
49+
}
50+
]
51+
}

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- trunk
6+
pull_request:
7+
8+
jobs:
9+
main:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- uses: nrwl/nx-set-shas@v3
16+
with:
17+
main-branch-name: 'trunk'
18+
- run: npm install -g yarn nx
19+
- run: yarn install --frozen-lockfile
20+
21+
- run: nx format:check
22+
- run: nx affected --target=lint --parallel=3
23+
# No test setup yet
24+
# - run: nx affected --target=test --parallel=3 --configuration=ci
25+
- run: nx affected --target=build --parallel=3

.gitignore

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,48 @@
1-
.DS_Store
2-
.idea
3-
.local
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
dist
5+
tmp
6+
var
7+
/out-tsc
48
.vitepress
5-
.vite
6-
.pnp.*
7-
.yarn/*
8-
!.yarn/patches
9-
!.yarn/plugins
10-
!.yarn/releases
11-
!.yarn/sdks
12-
!.yarn/versions
13-
.rollup.cache
9+
__pycache__
10+
11+
# dependencies
1412
node_modules
15-
/live-code-example
16-
/testwp
17-
package-lock.json
18-
packages/*/build
19-
testwp
20-
!build/wp-admin
21-
!build/wp-content
22-
!build/wp-includes
23-
!build/php.wasm
24-
!build/php.js
25-
!build/wp.data
26-
!build/wp.js
27-
*.tsbuildinfo
28-
*.d.ts
29-
tsdoc-metadata.json
30-
var
31-
dist.zip
13+
14+
# IDEs and editors
15+
/.idea
16+
/.local
3217
.vscode
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
32+
# misc
33+
/.sass-cache
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
npm-debug.log
38+
yarn-error.log
39+
testem.log
40+
/typings
41+
*.timestamp-1678999213403.mjs
42+
43+
# System Files
44+
.DS_Store
45+
Thumbs.db
46+
47+
# Playground artifacts
48+
php.js.bak

.nxignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
node_modules
2+
dist
3+
packages/php-wasm/node/public
4+
packages/php-wasm/web/public
5+
packages/php-wasm/compile/build-assets
6+
packages/playground/compile-wordpress/build-assets
7+
__pycache__
8+
packages/playground/remote/src/wordpress
9+
*.timestamp-1678999213403.mjs
10+
.local
11+
.vscode

.prettierignore

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
node_modules/**/*
2-
build/*
3-
packages/*/build*/*
1+
# Add files here to ignore them from prettier formatting
2+
/dist
3+
/coverage
4+
/node_modules
5+
/packages/php-wasm/node/public
6+
/packages/php-wasm/web/public
7+
/packages/php-wasm/compile/build-assets
8+
/packages/playground/compile-wordpress/build-assets
9+
/packages/playground/remote/src/wordpress
10+
__pycache__
11+
*.timestamp-1678999213403.mjs
12+
.local
13+
.vscode

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 4,
4+
"useTabs": true,
5+
"semi": true,
6+
"singleQuote": true
7+
}

.prettierrc.json

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

0 commit comments

Comments
 (0)