Open akirk opened 2 days ago
@psrpinto made a good point about the playground needing an "npm install playground" that contains everything you need.
Today you are relying on the Remote package from Playground.WordPress.net, or self-hosting. Having it as an NPM package should prevent issues where Remote isn't compatible with the Client version you got from NPM.
This would technically be npm install WordPress
🙂
I know there are size issues with remote because it has around 650MB of wasm, and WP asset files, but we could ship it with just the default version of PHP and WP.
Problem
Introducing new dependencies to Playground can cause unintended consequences for browser native imports of the Playground Client. This results in errors like
Which can be fixed by adding an importmap to unpkg.com but this can lead into a chain of further importmaps needed.
Working within in the Playground tooling these kind of changes go unnoticed but cause breakage. By adding an E2E test we can be warned about this and prevent that breakage from happening.
Background
Translate Live (e.g. https://translate.wordpress.org/projects/wp-themes/lms-education-courses/gl/default/playground/) loads the Playground client like this:
For this to work, it additionally needs to specify an importMap like this:
The last two of these,
ini
andajv
are already short-circuited versions of the libraries because they themselves causes many dependencies that are not required to run it. Specifically:https://translate.wordpress.org/wp-content/plugins/wporg-gp-playground/inc/routes/ajv.js
and https://translate.wordpress.org/wp-content/plugins/wporg-gp-playground/inc/routes/ini.js which is a manual conversion to cjs.