-
Notifications
You must be signed in to change notification settings - Fork 121
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
Webpack support #42
Comments
I think the compiled asm.js file itself should be webpack compatible. You could use the included If you compile with optimizations on (as you should), the Emscripten-generated |
Thanks, I'll check this. It however seems that |
That sounds like an oversight, I've only tested it with asm.js output in the |
I've been debugging your other issue in a browser, like this: <script src="build/Release/nbind.js"></script>
<script src="test.js"></script>
nbind.init(function(err, binding) {
var lib = binding.lib;
var point = new lib.Point(42, 66);
// ...
lib.test(point);
}); NOTE: I changed Webpack shouldn't have a problem with those scripts. The asm.js output is wrapped in UMD format, so you don't need to work with a global |
Is there a synchronous API ? I'm not sure asynchronous APIs are Webpack cup of tea (ideally, it should be able to resolve every module at build time, and chose itself whether they should be loaded asynchronously or not, so that the user isn't aware of the actual asset loading process) :( I'm currently using this code, but even if it works, it feels very hacky: var setupExports = require('./entry-common');
var hasRan = false;
var bind = null, lib = {};
var asmjs = require('../build/Release/nbind.js')
asmjs(lib, function (err, parts) {
if (err)
return;
hasRan = true;
bind = parts.bind;
});
if (!hasRan)
throw new Error('This module hasn\'t been correctly initialized');
setupExports(module, bind, lib); |
I know it's been a year since this issue had any work done on it but hoping you maybe able to help here... I'm trying to do an emscripten + webpack solution (which would likely be the same solution for nbind). That said, running into issues but I figure I would cross post and hopefully if my issues get resolved, maybe the solution can be applied here! |
I just noticed that nbind apparently isn't compatible with Webpack yet. Supporting it would be a great addition, especially since the asm.js compilation already works !
Basically, in order to be webpack-compliant, the loading should be greatly simplified to remove most of
require
calls, especially dynamic ones, at least in the browser codepath (Webpack can look for a"browser"
property in the package.json, instead of"main"
). For example, maybe by allowingnbind.init()
to take an argument that would actually be the asm.js file preloaded (so that all the requirement logic could be bypassed).The text was updated successfully, but these errors were encountered: