seanmorris / php-wasm

PHP in Browser, powered by WebAssembly.
https://seanmorris.github.io/php-wasm/
Apache License 2.0
606 stars 32 forks source link

Module not found: Can't resolve 'asm2wasm' #17

Closed kenorb closed 1 week ago

kenorb commented 2 years ago

Module not found: Can't resolve 'asm2wasm' in node_modules/php-wasm

It happens when I'm trying to run PhpWebDrupal in the app by:

const PhpWebDrupal = (await require('php-wasm/PhpWebDrupal')).PhpWebDrupal;

In comparison, PhpWeb is loading without this error.

seanmorris commented 2 years ago

@kenorb Are you using a bundler?

kenorb commented 2 years ago

I'm using php-wasm v0.0.5 in NextJS as part of this repo.

Here is the line which I'm changing to PhpWebDrupal (which generates the error):

https://github.com/mycognitive/Drupal8-demo/blob/221920d60bc84095c49ba5fb6c130fbcb4b713e9/src/components/Drupal.js#L13

seanmorris commented 2 years ago

Are you waiting for ready to fire?

php.addEventListener('ready', () => {
    php.run('<?php echo "Hello, world!";');
});
kenorb commented 2 years ago

Tested with ready state, same error. Works for PhpWeb, but not for PhpWebDrupal. It's possible that this can be Next.js specific, and it has trouble loading code in PhpWebDrupal.js properly.

seanmorris commented 2 years ago

Hmmm, on a hunch, does it work if you await require the asm2wasm module before the php-wasm module?

kenorb commented 2 years ago

I've tried, my friend tried, and we think something is missing in .wasm file, like asm2wasm (f64-rem and debugger) wasn't compiled into the file it-self or it was compiled for the different environment (not ENVIRONMENT=browser).