-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publish emsdk on npm + integrate with npm #5774
Comments
Do you know what other similar projects do that need e.g. LLVM to be bundled with them? Does npm architecture generally ship prebuilt binaries for each platform? |
Answering in reverse order:
Bundling precompiled binaries happens as well: In many projects native bindings C++/C code is built using Another example that just came to mind that actually bundles entire Chromium+V8 binaries is this: https://www.npmjs.com/package/electron-packager / https://github.com/electron-userland/electron-download.
The binaries don't necessarily need to be bundled with them. I can imagine you could re-use most of the existing emsdk install script and run it as an Initially, I was thinking the install script could look at the |
Even if emscripten were to be an npm module, without binaries the building takes forever, at least when I was trying to get everything set up to work with WebAssembly. What do people think about compiling Emscripten to WebAssembly? Once Node.js has full support for WebAssembly, we could use WASM as portable bytecode and just ship that, then there would be no building for each client, and Emscripten should work the same across all machines with Node.js WebAssembly support. |
At the moment Emscripten does run an infra to do precompile builds of each tag, so users don't have to build from source, unless they want the latest development branches. Probably |
That plan is to start using this top level node_modules directory for any/all node module dependencies. Ideally the SDK version would with pre-downloaded node_modules so that users don't need to download stuff on first use. See emscripten-core/emscripten#5774 See emscripten-core/emscripten#7538
Hey, wanting to use Emscripten in a package of my own - however it takes a long time to install (and it doesn't seem to work even when it finishes) I was hoping there was an NPM package that would do the install for me, but no such luck. |
I know it's a large task - but it does not seem unreasonable that emscripten itself could be compiled to WebAssembly, even if it's used in a node module. |
You'd have to start by compiler both python and llvm to emscripten since those are the core components of emscripten. Even with those tasks completed you'd need to figure out how to make sub-processes work. Emscripten forks many many subprocess. So yes, a mammoth task indeed. |
I suspect it's simpler to ship the existing emsdk in a way that's npm-friendly (installs into node_modules, downloads the necessary native binaries on-demand). Ideally it shouldn't have to modify a global ~/.emscripten file though; each instance must be able to have its own tool versions and config state. |
Yes, that is my understanding of what this issue is about, and seems orders of magnitude easier. |
nod quick overview of global bits:
If CLI settings or environment variables can be provided to override all of these, then wrappers for It may also be possible to run the various tool wrappers via |
Aha, there is an |
I'll see if I can cobble together a proof of concept this week wrapping emsdk into an npm module along those lines, see if anything obvious still needs adjusting. Would make it easier to break up my own projects into smaller modules since I'd have a common dependency to work with. :D |
If you want to make config etc local the install take a look at |
(emsdk's --embedded mode seems to set all the things I need. Coming along well!) |
Proof of concept that seems to work for me on Linux: https://github.com/brion/emsdk-npm ... went ahead and published it to npm for easy testing, I can iterate it from there or move/rename it to a final package name. This makes commands runnable within the node project via
In theory you should be able to do stuff like |
Oh -- this doesn't work on Windows yet, it may require a batch file to tie into |
Now works on Windows as well as Linux/Mac. Haven't tested the intermediate batch file with ... "extreme CLI args" yet but it should work. ;) |
Ok, looks like things took a positive turn here. So what do I do to get precompiled binaries? Or how do I compile it faster? Or do I use this 'emsdk-npm' package? |
cc @Brion |
Hmm... what Linux distribution are you running, and does it use a non-bash shell? |
@FreezePhoenix I've updated the package with a one-line fix (changed == to =) which should help with some non-bash shells. Let me know if that fixed it for you or if it's erroring out differently now. :D |
it's bash, pretty sure xd |
Now it just does nothing. Doesn't compile the files, doesn't do anything. Wait, hold up. More errors.
Seems like it doesn't like relative paths. |
@FreezePhoenix hmm, the If that's it, installing python 2 or python 3 (whichever gives you a |
Ahhh python needs to be installed. Turns out it does .-. " |
@FreezePhoenix ok, so it sounds like something's gone awry but it should be able to find python, so I'm not quite sure what's going wrong. Can you open an issue over on my repo and we'll debug it further over there? |
If anyone's interested, I've polished up @Brion's emsdk-npm and then I wrote a build library around it named emscripten-build to integrate with Node.js projects. Here are a few example use cases of this toolset. I appreciate any feedback as I'd like to publish these on NPM in the future. Resolved notes(resolved by emscripten-build-npm#2) I faced a couple concerns with how to handle EMSDK installing into
I resolved that the user should be allowed to specify their own EMSDK install path via a command line flag. If the end user specifies a custom install path, then all I appreciate any feedback on how to handle this scenario better and any other UX/technical feedback. I'd like to work towards publication on NPM. |
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant. |
Right now it's kind of kludgy to create npm packages that are built from C sources using Emscripten. Normally, when doing a local 'npm install', the devDependencies for the package are pulled from npm. But if Emscripten is a development dependency, people need to "manually" install emsdk, activate the right version, etc. It would be great if Emscripten could also be pulled from npm to 1) make this less kludgy 2) enable automatically activating the Emscripten/node/llvm versions required for the project in question, for example based on additional info in the package.json file.
The text was updated successfully, but these errors were encountered: