Oh boy, I wish I had started the FlexJS NPM module after you finished your Node.js support via AS3 :-D
Thanks for the tips. I had it in my TODOs to look at your npm dts2as utility. I will ping you when I get to the actual compilation of AS3 files via node part, hopefully soon. I might need some help to tweak my code to work on OSX as well. I am working on Windows at the moment. Thanks, Om On Tue, Dec 1, 2015 at 5:06 PM, Josh Tynjala <joshtynj...@gmail.com> wrote: > Oh, I see! I was confused. I now recall seeing that you were working on > getting FlexJS into NPM. > > I thought you meant that you were working on the compiler to add support > for Node.js modules. Getting the compiler to output good code for running > on Node.js is something that I hope to work on soon. > > For those not familiar, Node.js modules are referenced with calls to > require(), like this: > > var fs = require("fs"); > > It's almost like an import in ActionScript. I'm hoping to get the emitter > to output the right require() calls for any classes that are from CommonJS > modules used by Node.js. That's why I mentioned metadata. > > As far as NPM goes, let me share something that I learned while working on > my dts2as utility. If you want someone to be able to use commands like > asjsc directly from the command line, they need to install the package > globally. It won't work for packages installed locally. > > npm install -g flexjs > asjsc src/HelloWorld.as > > Okay, technically, you can run commands from local packages. It's just a > little messy, so I think people avoid it: > > npm install -g flexjs > ./node_modules/.bin/asjsc src/HelloWorld.as > > To get asjsc and other commands to work, you should be able to add them to > package.json. Here's how I did it in dts2as: > > "bin": { > "dts2as": "./bin/dts2as" > } > > For FlexJS, I think something like this should work: > > "bin": { > "asjsc": "./js/bin/asjsc", > "asjscompc": "./js/bin/asjscompc" > } > > - Josh > > On Tue, Dec 1, 2015 at 4:29 PM, OmPrakash Muppirala <bigosma...@gmail.com> > wrote: > > > My first goal is to mimic the Installer to get all the required > > dependencies (AIR, FlashPlayerGlobal.swc, Falcon, Google Closure etc.) > The > > problem here is that except for Google Closure, nothing else is available > > as a require dependency from npm. And Adobe AIR and Adobe > > FlashPlayerGlobal.swc need license agreement gates before downloading. > > > > So, I am creating a custon node.js module which calls > > download_dependencies.js in the prepublish lifecycle stage file which > takes > > care of prompting the user, downloading, unzipping and copying files > into > > place. So far so good. > > > > The next step would be to register mxmlc, compc, asjsc, etc. with npm (in > > package.json) and be able to call it from the command line. > > > > For the end user, it would be as simple as: > > > > npm install flexjs > > asjac src/HellowWorld.as > > > > I have been committing my changes to the feature-npm-install branch of > the > > flex-utilities repo: > > > > > https://github.com/apache/flex-utilities/tree/feature-npm-install/npm-flexjs > > > > Right now, I am working on getting the Falcon dependencies working (there > > are about a dozen of them) > > > > If there is a better way to do all this, I would love to hear it :-) > > > > Thanks, > > Om > > > > On Tue, Dec 1, 2015 at 4:12 PM, Josh Tynjala <joshtynj...@gmail.com> > > wrote: > > > > > I saw Om mention Node.js support in another thread. > > > > > > On Tue, Dec 1, 2015 at 3:38 PM, OmPrakash Muppirala < > > bigosma...@gmail.com> > > > wrote: > > > > > > > Right now, I am working on node.js support for FlexJS. > > > > > > > > > It's something that I'm very interested in, and I planned to work on > this > > > too, once I found some time. Om, can you go into more detail about how > > > you're planning to implement things? I was personally thinking that > > > metadata might be needed to define what should be passed to require() > for > > > modules, but I'd love to hear if you have something else in mind, and > > maybe > > > provide you with some additional feedback. > > > > > > - Josh > > > > > >