Skip to content

Conversation

@mho22
Copy link
Collaborator

@mho22 mho22 commented Dec 10, 2025

Motivation for the change, related issues

Runnin php-wasm-cli -v with the latest CLI resulted in :

ReferenceError: require is not defined
    at run (file:///wordpress-playground/packages/php-wasm/cli/src/main.ts:132:6)

Implementation details

Replace php.setSpawnHandler(require('child_process').spawn); with php.setSpawnHandler(spawn as SpawnHandler);

Testing Instructions (or ideally a Blueprint)

Before

node --no-warnings --experimental-wasm-stack-switching --experimental-wasm-jspi --loader=./packages/meta/src/node-es-module-loader/loader.mts ./packages/php-wasm/cli/src/main.ts -v

file:///wordpress-playground/packages/php-wasm/cli/src/main.ts:132
        php.setSpawnHandler(require('child_process').spawn);
            ^

ReferenceError: require is not defined
    at run (file:///wordpress-playground/packages/php-wasm/cli/src/main.ts:132:6)

After

node --no-warnings --experimental-wasm-stack-switching --experimental-wasm-jspi --loader=./packages/meta/src/node-es-module-loader/loader.mts ./packages/php-wasm/cli/src/main.ts -v

PHP 8.5.0-dev (cli) (built: Dec  9 2025 09:54:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.5.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.5.0-dev, Copyright (c), by Zend Technologies

@mho22 mho22 added [Type] Bug An existing feature does not function as intended [Feature] PHP.wasm [Package][@php-wasm] CLI labels Dec 10, 2025
@adamziel
Copy link
Collaborator

Good catch! It was a broken intermediate state between two PRs, #3008 fixed it so I'll close this one. We'll need some tests for php-wasm CLI to catch similar issues in CI.

@adamziel adamziel closed this Dec 10, 2025
@mho22
Copy link
Collaborator Author

mho22 commented Dec 10, 2025

@adamziel I added a task to create that specific test.

@mho22
Copy link
Collaborator Author

mho22 commented Dec 10, 2025

Aha! You already created that test 🎉 Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] PHP.wasm [Package][@php-wasm] CLI [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants