haxe-js-kit icon indicating copy to clipboard operation
haxe-js-kit copied to clipboard

Can I use webpack (or something similar) with these externs?

Open alexdmiller opened this issue 8 years ago • 2 comments

I recently posted this as a stack overflow question, but I guess it's also relevant to the author(s) of this library.

After I posted that question, I read the rest of this repo's README, and it looks like there is a mechanism for including require statements. So I guess I'll look into that. But then my question is: why not just use @:jsRequire("fs")?

alexdmiller avatar May 18 '16 05:05 alexdmiller

I started haxe-js-kit before there was @:jsRequire, that's why it includes its own require mechanism, for example here: https://github.com/clemos/haxe-js-kit/blob/develop/js/npm/socketio/Server.hx#L8 It's a macro that uses @:jsRequire under the hood (replaces implements ... with @:jsRequire and keeps track of all required libs).

Both @:jsRequire and npm.Package.Require work on the client side too (https://github.com/clemos/haxe-js-kit/tree/develop/js/browser), together with things like browserify. But haxe-js-kit doesn't "promote" them / use them for client libraries. I think it might be a good idea to tag these classes for use with browserify / webpack.

clemos avatar May 18 '16 08:05 clemos

I see. So all that's left to do is add lines like implements npm.Package.Require<"socket.io","1.0"> to client classes? I'm happy to create a PR to do that sometime this week.

Or would you prefer to switch over to using @:jsRequire?

alexdmiller avatar May 18 '16 16:05 alexdmiller