Skip to content

Make JS use a '.wasm' extension when importing the binary #313

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

Merged
merged 1 commit into from
Jun 25, 2018
Merged

Make JS use a '.wasm' extension when importing the binary #313

merged 1 commit into from
Jun 25, 2018

Conversation

jamen
Copy link
Contributor

@jamen jamen commented Jun 25, 2018

Relevant change is

-                format!("import * as wasm from './{}_bg';", module_name)
+                format!("import * as wasm from './{}_bg.wasm';", module_name)

So the JS output becomes:

import * as wasm from './foo_bg.wasm';

This works the same on Webpack and lets you use rollup and rollup-plugin-wasm. 🎉

There is an argument to be explicit about the extensions in module resolution, but this was mostly about the Rollup for me, so the commonjs output and the tests have the same tendency to not use .js extensions.

Other changes are auto removal of trailing whitespace.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat -- thanks @jamen !

@fitzgen fitzgen merged commit 5adda0d into rustwasm:master Jun 25, 2018
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