
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
parcel-plugin-emscripten
Advanced tools
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
Plugin
We found that parcel-plugin-emscripten demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.