Socket
Book a DemoInstallSign in
Socket

parcel-plugin-emscripten

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parcel-plugin-emscripten

Plugin

latest
Source
npmnpm
Version
0.2.0
Version published
Maintainers
1
Created
Source

Parcel plugin for Emscripten

Build Status

A Parcel plugin to enable importing a C(++) file inside a JS file.

Emscripten has to be installed and emcc needs to be in PATH.

Example:

import Module from './test.c';
const Instance = Module();

Instance.then(()=>{
    console.log(Instance._add(10,20));
});

// equivalent to

Instance.then((v)=>{
    console.log(v._add(10,20));
});
//test.c
#include <emscripten.h>

int EMSCRIPTEN_KEEPALIVE add(int x, int y) {
    return x + y;
}

For more complex examples, see the example directory.

Instance.then is quite fragile and not a thenable, see https://github.com/kripken/emscripten/issues/5820

Using multiple Modules (= importing multiple C files) is supported, but it isn't very filesize efficient. Consider writing a single C-wrapper and importing that instead!

To pass additional arguments to emcc (change optimization, link another C file or a library, ...), specify them in the first line of your main C file: (this would disable optimizations and compile and link lib.c as well)

//parcel: -O0 lib.c
#include ...

FAQs

Package last updated on 13 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts