Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Playground CLI] Remove dependency on @php-wasm/web for significantly smaller install size #2131

Open
eliot-akira opened this issue Jan 17, 2025 · 0 comments

Comments

@eliot-akira
Copy link
Collaborator

The initial install size of @wp-playground/cli is quite big because it depends on both @php-wasm/node and @php-wasm/web. They include all available PHP versions (10) in 2 variants (asyncify and jspi) for 2 targets (node and web).

For example, in an empty project:

$ mkdir example && cd example
$ bun init -y
$ du -sh .
27M
$ bun add @wp-playground/cli && du -sh .
606M
$ du -sh node_modules/@php-wasm/* | sort -hr | head -n2
293M    node_modules/@php-wasm/node
249M    node_modules/@php-wasm/web

I think I found a way to remove dependency on the web target, and reduce the install size by half.

Searching for where it's being used:

$ npm ls @php-wasm/web
example@
└─┬ @wp-playground/[email protected]
  └─┬ @wp-playground/[email protected]
    ├── @php-wasm/[email protected]
    └─┬ @wp-playground/[email protected]
      └── @php-wasm/[email protected] deduped

I grepped for @php-wasm/web in the cli, blueprints, and storage packages - and found only two lines.

import { fetchWithCorsProxy } from '@php-wasm/web';

import type { MountDevice } from '@php-wasm/web';

In @php-wasm/web, the function fetchWithCorsProxy (here) and type MountDevice (here) are very small and self-contained. They don't depend on anything in the rest of the package.

If these could be moved to a target-agnostic package like @php-wasm/universal, then blueprints and storage can import from there and avoid having to depend on the entire web target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Inbox
Development

No branches or pull requests

1 participant