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

Better support for wasm and import.meta #2771

Closed
wants to merge 1 commit into from
Closed

Better support for wasm and import.meta #2771

wants to merge 1 commit into from

Conversation

matthewp
Copy link
Contributor

@matthewp matthewp commented Mar 2, 2021

Changes

This adds the import meta rollup extension which will copy assets that use this pattern:

new URL('./compiler.wasm', import.meta.url);

Among other things, this helps support for wasm when the above pattern is used.

This will also help with other types of static assets loaded this way, such as images.

Testing

  • Test added which uses import.meta.url to load a wasm file. Test ensures the file is copied to the output directory.
  • Test also use the pattern on a fake API. This verifies that we don't choke up if there isn't a "file" associated with a URL. These get ignored.

Docs

No docs published yet. Should there be?

@vercel
Copy link

vercel bot commented Mar 2, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/6Bod5Rrdrfe3dHWANLZGHob4uGaQ
✅ Preview: https://snowpack-git-wasm-pikapkg.vercel.app

This adds the import meta rollup extension which will copy assets that use this pattern:

```js
new URL('./compiler.wasm', import.meta.url);
```

Among other things, this helps support for wasm when the above pattern is used.

* Rust now uses this pattern, so bundlers can include the wasm file. https://twitter.com/RReverser/status/1365342246653018115
* Emscripten (compiles C/C++) is working on support: emscripten-core/emscripten#13571 (comment)

This will also help with other types of static assets loaded this way, such as images.
@matthewp
Copy link
Contributor Author

matthewp commented Mar 4, 2021

I think there might be an issue with the plugin I added support for Node 14. Feel free to close this, I'll get around to looking into it eventually.

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.

2 participants