Comments (8)
I'd definitely be on board with this! I like the idea of "given the set of nice imports give me a set of low-level imports" as well as the reverse for the exports. Would you be interested in trying your hand at adding these?
from wasm-bindgen.
Great, thanks for the quick response! Yes, I'd be happy to give it a try. It looks like the key file is crates/wasm-bindgen-cli-support/src/ts.rs. Any parallel spots I should look for?
from wasm-bindgen.
Nah yeah that's it! The file isn't exactly the cleanest of files, but you can see the template down at the bottom
from wasm-bindgen.
@TimHambourger ah so actually, you may wish to hold off! I was having some discussion today with others and actually I think the current approach to the wasm module isn't quite right. I think we'll want to generate wasm/js files differently to better respect ES6 module integration with wasm.
I'll try to update this repo soon!
from wasm-bindgen.
As a general overview though what I'd hope to do is to actually generate a JS file file that starts with something like:
import * as wasm from './low-level.wasm';
in the sense that the instantiation of the wasm module would largely be up to the bundler rather than this library.
from wasm-bindgen.
Ok! I've rewritten the bindgen tool at the es6-modules branch -- https://github.com/alexcrichton/wasm-bindgen/tree/es6-modules, with some notable info in the commit message.
@TimHambourger mind giving that a spin and see if it works for you?
from wasm-bindgen.
Ah ok I went ahead and merged to master so this should be fixed now!
from wasm-bindgen.
@alexcrichton You move fast! Thanks for the updates and sorry to take a couple days to get back.
I definitely appreciate the desire to move instantiation out of this library. I've seen other tools that take a wasm-as-module approach, e.g. wasm-loader for webpack. I like the concept - treat wasm like just another code asset. It seems like the trade-off is less control over how/when the wasm gets compiled and instantiated. Or at least, the existing bundlers I've seen don't seem to give that kind of control. I'm also seeing different APIs from the different bundlers. E.g. wasm-loader
exports a different API than your wasm2es6js
. So there's some danger of becoming dependent on a particular bundler.
But those questions aside, the latest code is working great otherwise. So I'm happy leaving this one closed. And I'm excited to see where the library goes from here. All cool stuff!
from wasm-bindgen.
Related Issues (20)
- Schema Version Mismatch Error when Using `cargo leptos watch` in WSL Ubuntu Environment
- export names as they are
- Generated binary crashes with "RuntimeError: memory access out of bounds"
- getter macro inconsistent behavior in Release/Debug builds HOT 3
- Uncaught TypeError: Cannot read properties of undefined (reading 'length')
- After extending web_sys with an IDL, when running` cargo doc --all-features --open` I get an erroneous can't find type error
- Automatic deallocation by `FinalizationRegistry` does not work for fully synchronous code HOT 4
- wasm-bindgen is broken and untested at MSRV (1.57) HOT 1
- Missing WebIDL processing features overview HOT 3
- wasm-audio-worklet example gives tons of warnings and some errors
- Expose synchronous XMLHttpRequest HOT 2
- Exports with `#[wasm_bindgen(js_name = default)]` gets exported as `fn _default`
- Trait-based Web API bidnings HOT 2
- `new` constructors for WebIDL bindings introduce undefined behavior by not setting default values HOT 2
- Splitting into multiple lazily-loaded modules HOT 17
- Could I send an option with Element to js function? HOT 2
- `wasm-bindgen` 0.2.92 triggers `clippy::mem_forget` HOT 2
- `wasm-bindgen` appears to trigger new `clippy` lint `clippy::empty_docs` HOT 2
- "memory access out of bounds" on allocating large structs.
- Promise's `then` method doesn't support Closures with return values HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasm-bindgen.