php-wasm
php-wasm copied to clipboard
Module not found: Can't resolve 'asm2wasm'
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 Are you using a bundler?
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
Are you waiting for ready to fire?
php.addEventListener('ready', () => {
php.run('<?php echo "Hello, world!";');
});
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.
Hmmm, on a hunch, does it work if you await require the asm2wasm module before the php-wasm module?
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).