forked from rustwasm/wasm-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a
raw_module
attribute to #[wasm_bindgen]
This allows subverting the checks and resolution performed by the `module` attribute added as part of [RFC 6] and has been discussed in rustwasm#1343. Closes rustwasm#1343 [RFC 6]: rustwasm/rfcs#6
- Loading branch information
1 parent
9e74085
commit 0d592ff
Showing
8 changed files
with
61 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
guide/src/reference/attributes/on-js-imports/raw_module.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# `raw_module = "blah"` | ||
|
||
This attribute performs exactly the same purpose as the [`module` | ||
attribute](module.html) on JS imports, but it does not attempt to interpret | ||
paths starting with `./`, `../`, or `/` as JS snippets. For example: | ||
|
||
```rust | ||
#[wasm_bindgen(raw_module = "./some/js/file.js")] | ||
extern "C" { | ||
fn the_function(); | ||
} | ||
``` | ||
|
||
Note that if you use this attribute with a relative or absolute path, it's | ||
likely up to the final bundler or project to assign meaning to that path. This | ||
typically means that the JS file or module will be resolved relative to the | ||
final location of the wasm file itself. That means that `raw_module` is likely | ||
unsuitable for libraries on crates.io, but may be usable within end-user | ||
applications. |