php-wasm icon indicating copy to clipboard operation
php-wasm copied to clipboard

Module not found: Can't resolve 'asm2wasm'

Open kenorb opened this issue 3 years ago • 6 comments

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.

kenorb avatar Jun 25 '22 22:06 kenorb

@kenorb Are you using a bundler?

seanmorris avatar Jun 27 '22 10:06 seanmorris

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

kenorb avatar Jun 27 '22 12:06 kenorb

Are you waiting for ready to fire?

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

seanmorris avatar Jun 27 '22 16:06 seanmorris

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.

kenorb avatar Jun 28 '22 18:06 kenorb

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

seanmorris avatar Jun 28 '22 19:06 seanmorris

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).

kenorb avatar Jun 29 '22 16:06 kenorb