Code Monkey home page Code Monkey logo

Comments (8)

alexcrichton avatar alexcrichton commented on May 22, 2024

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.

TimHambourger avatar TimHambourger commented on May 22, 2024

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.

alexcrichton avatar alexcrichton commented on May 22, 2024

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.

alexcrichton avatar alexcrichton commented on May 22, 2024

@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.

alexcrichton avatar alexcrichton commented on May 22, 2024

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.

alexcrichton avatar alexcrichton commented on May 22, 2024

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.

alexcrichton avatar alexcrichton commented on May 22, 2024

Ah ok I went ahead and merged to master so this should be fixed now!

from wasm-bindgen.

TimHambourger avatar TimHambourger commented on May 22, 2024

@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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.