Skip to content

Commit b150e6e

Browse files
authored
Update Playground Node version to 20.9.0 (#89)
## Motivation for the change, related issues [Playground depends on crypto](https://github.com/WordPress/wordpress-playground/blob/07fb8bac24f02db0c40a2f465597a05021c01d7e/packages/playground/website/src/lib/site-metadata.ts#L82) which isn't available in Node 18, which [is preventing us from creating Playground CLI tests.](Automattic/wordpress-playground-private#39 (comment)) In the past, we kept the [Node version at 18 to ensure Playground works in Electron apps like VSCode and Studio](#591 (comment)). Today Electron includes Node 20, so we are safe to update. I chose Node 20.9.0 because it's the version of Node that Studio uses. ## Implementation details To update Playground I did the following: - Update the Node version in all package.json files - Updated `.nvmrc` - Update the Node version used in CI - Set a minimal Node version Emscripten should target - Update Node tyles - Ran `npm install` - Checked manually if there are any mentions of Node 18 or polyfills that we can remove. This PR also adds a global `vitest.setup.ts` file with some JSDOM function polyfills/replacements. This was required because JSDOM replaces the existing Node.js APIs with their versions of Web APIs, and sometimes these APIs are missing features already supported in Node.js. Read [the comment in vitest.setup.ts for more details.](https://github.com/Automattic/wordpress-playground-private/blob/update/min-node-version-to-20/vitest.setup.ts) ## Testing Instructions (or ideally a Blueprint) - CI
1 parent 5a3551d commit b150e6e

File tree

102 files changed

+110796
-125077
lines changed

Some content is hidden

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

102 files changed

+110796
-125077
lines changed

.github/actions/prepare-playground/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
type: string
66
required: true
77
description: 'Node.js version to use'
8-
default: '18'
8+
default: '20'
99

1010
runs:
1111
using: 'composite'

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
submodules: true
3333
- uses: ./.github/actions/prepare-playground
3434
with:
35-
node-version: 22
35+
node-version: 20
3636
- run: node --expose-gc node_modules/nx/bin/nx affected --target=test --configuration=ci
3737
# Most of these tests pass locally but the process is crashing
3838
# on the CI runner.

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.18.0
1+
v20.9.0

package-lock.json

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

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
"@types/ajv": "1.0.0",
134134
"@types/file-saver": "^2.0.5",
135135
"@types/jest": "^29.4.0",
136-
"@types/node": "18.14.2",
136+
"@types/node": "20.9.0",
137137
"@types/react": "18.3.3",
138138
"@types/react-dom": "18.3.0",
139139
"@types/react-modal": "3.16.3",
@@ -223,7 +223,7 @@
223223
"packages/playground/*"
224224
],
225225
"engines": {
226-
"node": ">=16.15.1",
227-
"npm": ">=8.11.0"
226+
"node": ">=20.9.0",
227+
"npm": ">=10.1.0"
228228
}
229229
}

packages/nx-extensions/src/executors/package-for-self-hosting/executor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default async function packageForSelfHostingExecutor(
121121
pack.pipe(zlib.createGzip())
122122
.pipe(tarballWriteStream)
123123
.on('error', reject)
124-
.on('finish', resolve);
124+
.on('finish', () => resolve(null));
125125
});
126126

127127
return { success: true };

packages/php-wasm/cli/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default defineConfig(() => {
4444
},
4545
environment: 'jsdom',
4646
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
47+
setupFiles: ['../../../vitest.setup.ts'],
4748
},
4849
};
4950
});

packages/php-wasm/compile/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"type": "module",
2121
"gitHead": "a0eeb66fd5386bb56715fca2b89e9669a5b8618b",
2222
"engines": {
23-
"node": ">=18.18.0",
24-
"npm": ">=8.11.0"
23+
"node": ">=20.9.0",
24+
"npm": ">=10.1.0"
2525
}
2626
}

packages/php-wasm/compile/php/Dockerfile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,15 +1062,16 @@ RUN set -euxo pipefail; \
10621062
$(cat /root/.emcc-php-wasm-flags) \
10631063
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCTIONS" \
10641064
-s WASM_BIGINT=1 \
1065+
-s MIN_NODE_VERSION=200900 \
10651066
-s INITIAL_MEMORY=1024MB \
1066-
-s ALLOW_MEMORY_GROWTH=1 \
1067-
-s ASSERTIONS=0 \
1068-
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
1069-
-s NODEJS_CATCH_EXIT=0 \
1070-
-s NODEJS_CATCH_REJECTION=0 \
1071-
-s INVOKE_RUN=0 \
1067+
-s ALLOW_MEMORY_GROWTH=1 \
1068+
-s ASSERTIONS=0 \
1069+
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
1070+
-s NODEJS_CATCH_EXIT=0 \
1071+
-s NODEJS_CATCH_REJECTION=0 \
1072+
-s INVOKE_RUN=0 \
10721073
-o /build/output/php.js \
1073-
-s EXIT_RUNTIME=1 \
1074+
-s EXIT_RUNTIME=1 \
10741075
-Wl,--wrap=select \
10751076
/root/lib/libphp.a \
10761077
/root/proc_open.c \

packages/php-wasm/fs-journal/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"license": "GPL-2.0-or-later",
4040
"gitHead": "2f8d8f3cea548fbd75111e8659a92f601cddc593",
4141
"engines": {
42-
"node": ">=18.18.0",
43-
"npm": ">=8.11.0"
42+
"node": ">=20.9.0",
43+
"npm": ">=10.1.0"
4444
}
4545
}

packages/php-wasm/fs-journal/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ export default defineConfig({
4848
},
4949
environment: 'jsdom',
5050
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
51+
setupFiles: ['../../../vitest.setup.ts'],
5152
},
5253
});

packages/php-wasm/logger/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"main": "./index.cjs",
2525
"types": "index.d.ts",
2626
"engines": {
27-
"node": ">=18.18.0",
28-
"npm": ">=8.11.0"
27+
"node": ">=20.9.0",
28+
"npm": ">=10.1.0"
2929
}
3030
}

packages/php-wasm/logger/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ export default defineConfig({
4848
},
4949
environment: 'jsdom',
5050
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
51+
setupFiles: ['../../../vitest.setup.ts'],
5152
},
5253
});

packages/php-wasm/node-polyfills/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Polyfills JavaScript classes and methods required by WordPress Playground.
44

55
Ensures compatibility with the following environments:
66

7-
- Node.js >= 18
7+
- Node.js >= 20
88
- JSDom
99

1010
## Building
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
import './lib/blob';
22
import './lib/custom-event';
3-
import './lib/url';

packages/php-wasm/node-polyfills/src/lib/blob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (currentJsRuntime === 'NODE') {
1818
* just need to implement a few File-specific properties.
1919
*/
2020
class File extends Blob {
21-
override readonly name;
21+
readonly name: string;
2222
readonly lastModified: number;
2323
readonly lastModifiedDate: Date;
2424
webkitRelativePath: any;

packages/php-wasm/node-polyfills/src/lib/url.ts

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

packages/php-wasm/node-polyfills/vitest-jsdom.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export default {
66
test: {
77
...config.test,
88
environment: 'jsdom',
9+
setupFiles: ['../../../vitest.setup.ts'],
910
},
1011
};

0 commit comments

Comments
 (0)