forked from WordPress/playground-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate to NX-based build (WordPress#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 WordPress#150) * Cross-package TypeScript just works * There are linters and formatters (which solves WordPress#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
- Loading branch information
Showing
1,069 changed files
with
93,064 additions
and
102,107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Editor configuration, see http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_style = space | ||
indent_size = 2 | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
max_line_length = off | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
node_modules/**/* | ||
build/* | ||
packages/*/build*/* | ||
src/php-wasm/wasm/build-assets/* | ||
node_modules | ||
packages/php-wasm/node/public | ||
packages/php-wasm/web/public | ||
packages/php-wasm/compile/build-assets | ||
packages/playground/compile-wordpress/build-assets | ||
__pycache__ | ||
packages/playground/remote/src/wordpress | ||
*.timestamp-1678999213403.mjs | ||
.local | ||
.vscode |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"root": true, | ||
"ignorePatterns": ["**/*"], | ||
"plugins": ["@nrwl/nx"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": { | ||
"@nrwl/nx/enforce-module-boundaries": [ | ||
"error", | ||
{ | ||
"enforceBuildableLibDependency": true, | ||
"allow": [], | ||
"depConstraints": [] | ||
} | ||
], | ||
"no-inner-declarations": 0, | ||
"no-use-before-define": "off", | ||
"react/prop-types": 0, | ||
"no-console": 0, | ||
"no-empty": 0, | ||
"no-async-promise-executor": 0, | ||
"no-constant-condition": 0, | ||
"no-nested-ternary": 0, | ||
"jsx-a11y/click-events-have-key-events": 0, | ||
"jsx-a11y/no-static-element-interactions": 0 | ||
} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"extends": ["plugin:@nrwl/nx/typescript"], | ||
"rules": { | ||
"@typescript-eslint/ban-ts-comment": 0, | ||
"@typescript-eslint/ban-types": 0, | ||
"@typescript-eslint/no-non-null-assertion": 0, | ||
"@typescript-eslint/no-explicit-any": 0, | ||
"no-constant-condition": 0 | ||
} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"extends": ["plugin:@nrwl/nx/javascript"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": "*.json", | ||
"parser": "jsonc-eslint-parser", | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: CI | ||
on: | ||
push: | ||
branches: | ||
- trunk | ||
pull_request: | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- uses: nrwl/nx-set-shas@v3 | ||
with: | ||
main-branch-name: 'trunk' | ||
- run: npm install -g yarn nx | ||
- run: yarn install --frozen-lockfile | ||
|
||
- run: nx format:check | ||
- run: nx affected --target=lint --parallel=3 | ||
# No test setup yet | ||
# - run: nx affected --target=test --parallel=3 --configuration=ci | ||
- run: nx affected --target=build --parallel=3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,48 @@ | ||
.DS_Store | ||
.idea | ||
.local | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
dist | ||
tmp | ||
var | ||
/out-tsc | ||
.vitepress | ||
.vite | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions | ||
.rollup.cache | ||
__pycache__ | ||
|
||
# dependencies | ||
node_modules | ||
/live-code-example | ||
/testwp | ||
package-lock.json | ||
packages/*/build | ||
testwp | ||
!build/wp-admin | ||
!build/wp-content | ||
!build/wp-includes | ||
!build/php.wasm | ||
!build/php.js | ||
!build/wp.data | ||
!build/wp.js | ||
*.tsbuildinfo | ||
*.d.ts | ||
tsdoc-metadata.json | ||
var | ||
dist.zip | ||
|
||
# IDEs and editors | ||
/.idea | ||
/.local | ||
.vscode | ||
.project | ||
.classpath | ||
.c9/ | ||
*.launch | ||
.settings/ | ||
*.sublime-workspace | ||
|
||
# IDE - VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/coverage | ||
/libpeerconnection.log | ||
npm-debug.log | ||
yarn-error.log | ||
testem.log | ||
/typings | ||
*.timestamp-1678999213403.mjs | ||
|
||
# System Files | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Playground artifacts | ||
php.js.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
node_modules | ||
dist | ||
packages/php-wasm/node/public | ||
packages/php-wasm/web/public | ||
packages/php-wasm/compile/build-assets | ||
packages/playground/compile-wordpress/build-assets | ||
__pycache__ | ||
packages/playground/remote/src/wordpress | ||
*.timestamp-1678999213403.mjs | ||
.local | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
node_modules/**/* | ||
build/* | ||
packages/*/build*/* | ||
# Add files here to ignore them from prettier formatting | ||
/dist | ||
/coverage | ||
/node_modules | ||
/packages/php-wasm/node/public | ||
/packages/php-wasm/web/public | ||
/packages/php-wasm/compile/build-assets | ||
/packages/playground/compile-wordpress/build-assets | ||
/packages/playground/remote/src/wordpress | ||
__pycache__ | ||
*.timestamp-1678999213403.mjs | ||
.local | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 4, | ||
"useTabs": true, | ||
"semi": true, | ||
"singleQuote": true | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.