Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ballercat/momo-loader
:dizzy: Momo to wasm loader for Webpack
https://github.com/ballercat/momo-loader
Last synced: 30 days ago
JSON representation
:dizzy: Momo to wasm loader for Webpack
- Host: GitHub
- URL: https://github.com/ballercat/momo-loader
- Owner: ballercat
- License: mit
- Created: 2017-06-18T14:47:03.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-18T15:37:02.000Z (over 7 years ago)
- Last Synced: 2024-10-03T09:34:53.207Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# momo file loader for webpack
Checkout [momo-language](https://github.com/maierfelix/momo) here. The fastest way to get up and running with WebAssembly.
This loader converts `.momo` files to `wasm` bytecode.
## Install
```
npm install --save-dev momo-loader wasm-loader
```# Usage
Edit webpack.config.js:
```javascript
resolve: [
extensions: ['.js', '.momo']
],
...
loaders: [
{
test: /\.wasm$/,
loaders: ['wasm-loader', 'momo-loader']
}
]
```You can refer to `example.webpack.config.js` in this repo for an example.
# Example
Here we are going to use main.momo example, and save it to `/momo/main.momo`:
```c
int swap(int *c, int *d) {
int tmp = *c;
*c = *d;
*d = tmp;
return (0);
};extern int main() {
int a = 10;
int b = 20;
int &rb = b;
rb = 33;
swap(&a, &rb);
return (a);
};
```Later simply include the file in your JavaScript and instantiate the module:
```javascript
import Main from '/momo/main';const mainInstance = new Main();
console.log(mainInstance.exports.main()) // 33
```That's it.