-
-
Notifications
You must be signed in to change notification settings - Fork 676
Closed
Labels
Description
Hey guys,
I'm looking to create a React-like framework for AssemblyScript. How could I import my project into another assemblyscript project (the user one) ?
I was thinking about creating my library then compile it to wasm and to use/import it with the loader, bridge all methods to the other.
Example:
if ('WebAssembly' in window) {
fetch('MY_REACT_LIKE_LIBRARY.wasm')
.then(response => response.arrayBuffer())
.then(buffer => WebAssembly.instantiate(buffer, {
// AUTOMATIC JAVASCRIPT IMPORT
}))
.then(reactLikeLibrary => {
fetch('USER_AS_PROJECT.wasm')
.then(response => response.arrayBuffer())
.then(buffer => WebAssembly.instantiate(buffer, {
// AUTOMATIC IMPORT OF 'MY_REACT_LIKE_LIBRARY.wasm' LIBRARY
// + USER IMPORT
}))
.then(userProject => {
const instance = userProject.instance;
// CALL MAIN FUNCTION
instance.exports.main()
})
.catch(console.error);
})
.catch(console.error);
} else {
alert("Your browser doesn't support Web Assembly. You may need " +
"to enable it in your browser's flags.");
}
(Of couse, this code will be bundled with the library and be more like the assemblyscript loader)
Is there a clever solution for doing this ? Import directly the code from the user AS code (like npm package : without carring sources in the directory) ?
Thanks,