modular-js
modular-js copied to clipboard
@:jsRequire support
Right now the generator doesn't seem to recognise externs with @:jsRequire as dependencies. That would be really useful and allow mixing with node_module code through browserify or webpack.
Yes, I have plans for this. Stay tuned.
I see that @:jsRequire
support appears to be here?
One question -- what if I want to require the whole Pixi.js library? Is there a syntax for that? If I put a @:jsRequire
on, for example, the Pixi Matrix class:
@:native("PIXI.Matrix") @:jsRequire("PIXI.Matrix")
extern class Matrix {
It ends up generating a define header like this:
define(["PIXI.Matrix", "../../extend_stub"],
function (PIXI_Matrix, extend_stub) {
var m = new PIXI_Matrix();
But pixi is a single, bundled .js file, so what I really what is this:
define(["PIXI", "../../extend_stub"],
function (PIXI, extend_stub) {
var m = new PIXI.Matrix();
Is this possible with the current @:jsRequire
schema?
FYI, over on my fork I've implemented this feature -- I call it require namespaces.
This allows me to require a large project, like Pixi.JS, and reference the classes therein.
e.g. the Pixi.js Matrix extern is defined like so:
@:native("PIXI.Matrix")
extern class Matrix {
The JS generator, when run with -D RequireNamespaces=PIXI
, will see that PIXI prefix, and add a dependency on 'PIXI', while locally referencing the variable as PIXI.Matrix
. e.g.
define(['PIXI'], function(PIXI) {
...
var m = new PIXI.Matrix();
});