buttplugio / buttplug-rs-ffi

FFI from buttplug-rs to Java and other languages
Other
88 stars 22 forks source link

JS/WASM 1.0.15 loading broken #88

Closed blackspherefollower closed 3 years ago

blackspherefollower commented 3 years ago

Describe the bug Calling buttplugInit() will result in:

Error: Cannot find module '<url>'
    at src lazy prefetchOrder: 1 namespace object:5
    at async Module.g (ffi.ts:37)
    at async clickHandler (script.js:7)

This happens with or without a provided url as an argument.

I narrowed down the problem to fe66645f which made the module import path an argument. This turns out to prevent webpack from rewriting the path during build to reflect the build target.

I've thrown together a "fix" on https://github.com/blackspherefollower/buttplug-rs-ffi/commit/bea85bbf48926be62fa1030dce277372b7226c0d which resolves issue when path no-argument is provided.

However:

  1. Providing a path to 1.0.15's buttplugInit() results in the same error as without (except the path in the error is changed). This is due to the webpack build failing to resolve a value and so building in a placeholder error report instead. Example: https://glitch.com/edit/#!/ripple-slender-nitrogen?path=script.js%3A7%3A113
  2. In my "fix" I've sed the magic comment /* webpackIgnore: true */ to overcome the build-time error and allow for the module to be loaded at runtime, but this results in the error Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/wasm". Strict MIME type checking is enforced for module scripts per HTML spec. being returned instead.