Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to match the changes in wasm-bindgen #31

Merged
merged 1 commit into from Jun 1, 2020

Conversation

rrbutani
Copy link
Contributor

I tried to switch to using --target web (and --target node for node) as @Pauan suggested, but ran into some trouble. My attempt is here but the key points are that:

  • the use of import.meta in the JS that wasm-bindgen produces with --target web is problematic because:

Just using the bundler target without any "custom parsing" doesn't work because parcel's built-in wasm loaders (here and here) don't pass in any imports.

By contrast, webpack does the right here which is why its' plugin doesn't need to remap the imports/exports and manually import the wasm blob. This other parcel plugin also uses the bundler target and remaps the imports and exports but then appears to go and replace the default parcel wasm loader with their own version that takes imports as an arg (this plugin effectively does the exact same thing, I think).

It seems like if this plugin were to use --target web and manually substitute the import.meta call for the actual file name of the wasm blob (and then also make it so parcel picks up and serves the blob) things would work. I'm not sure what the best way to do the latter thing is (raw asset? just copy it into the output directory? I know that putting it in generated under the wasm key won't work since, again, the default wasm loader doesn't support imports).

I'm also not sure that the workaround above (assuming it'd work) is actually appreciably better than the current way of doing things (it'd be more resilient to changes in how, for example, enums are exported in wasm-bindgen and that sort of thing but I don't know if it matters). In any case, I'm not very familiar with JavaScript build tooling so I thought I'd write all this out and make sure I'm not completely wrong about the above or missing something.

In the meantime, as the commit says, here's a stopgap that just goes and uses the _bg.js file where it's needed so things work as they did before.

This closes #30.

@catsigma
Copy link
Collaborator

catsigma commented Jun 1, 2020

thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken with latest version of wasm-bindgen
2 participants