Comments (2)
I think you're misunderstanding how WebAssembly modules work.
You can import functions given a module + function name, such as (env
, addNumbers
).
You can export a function with a particular name, such as addNumbers
. You can also export it with extra characters in there, so that the function name becomes env_addNumbers
, env::addNumbers
, env.addNumbers
, or anything you like. There's nothing special about that dot, it's just a function name.
Specifically here:
As I mentioned, the JS-clue shouldn't know about exported methods and it should just copy all methods from a particular export section, e.g.:
// Copy all exported methods in "env" object go.importObject.env = { ...guestMod.instance.exports.env }
It doesn't work like that. There are no named export sections, just one (unnamed) section with exported functions. You can export addNumbers
(or env.addNumbers
or whatever), but it's a plain old function name.
Perhaps you can try using Developer Tools and inspect the Module object manually? That may give a better idea of how it works.
from tinygo.
Thanks for the explanation, @aykevl! I appreciate your help!
Now I understand your point. I realized that there's a new target wasm-unknown
in new releases that drastically reduces the emitted functions and generates a pure module without any dependencies. It looks like I can leverage that to implement what I need. Thanks
from tinygo.
Related Issues (20)
- Partial TLS support for wasm
- nrf: writes via `machine.Flash` cause assertion violations with SoftDevice enabled HOT 1
- `wasm-unknown` target doesn't define `memset` or `memcpy` HOT 2
- No support for new ARM softfloat/hardfloat distinction added in Go 1.22 HOT 6
- Bus Error on Raspberry Pi 4 B When Running Linked List Append HOT 1
- Joystick USB HID device - changing identity HOT 2
- Hello, thank you Tinygo. Can I use ESP8266's WiFi now HOT 1
- //go:linkname doesn't work for already defined functions HOT 4
- wasm file generation error: package net/http/httptrace is not in std HOT 3
- esp32-cam support
- Support for RV32IM HOT 4
- don't allocate closure variables if the closure doesn't escape
- Joystick axes reduced by 2 for values of >2 in range -32767..32767 on Windows HOT 1
- esp8266 wifi support HOT 1
- go install failing in go-llvm HOT 1
- core: compile failures due to SSA race condition HOT 29
- No space between hexadecimal literal and identifier HOT 2
- feature: add support for esp32c3 supermini board HOT 3
- panic: interp: load out of bounds on unsafe.SliceData of zero cap slice
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 tinygo.