flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Tynjala <joshtynj...@gmail.com>
Subject [FalconJX] More Node.js stuff
Date Thu, 21 Apr 2016 21:01:13 GMT
Hey folks,

I've been working on improving Node.js support for the next release of
FlexJS. Sorry for forcing you to wipe your builds of flex-falcon after I
added new externs downloads!

In FlexJS 0.6, you could use require() to load Node modules, but you'd have
untyped objects:

var http:Object = require("http");

It's just enough to make things work, but you probably wouldn't want to do
a whole project that way.

Starting today, if a class in an externs SWC has [JSModule] metadata, the
compiler will automatically require the module in the generated JS.

package {
    public class http {}

package http
    public class Server {}

If you use http or http.Server in your ActionScript code, the compiler will
know to require it in the generated JavaScript.

In the process, I fixed several issues in externc. I also added a new
named-module command line argument to externc that lets you specify exactly
which packages should include [JSModule] metadata. I updated the Node.js
externs, and it works great!

Here's a little example:

    public class HelloNode
        public function HelloNode()
            var newPath:String =

The path class is required automatically by the compiler. It's in the
top-level package, so it doesn't need to be imported. Classes in
sub-packages are imported normally in ActionScript. The console class is
used in this example too, but because it considered a global, it doesn't
have [JSModule] metadata, so it gets treated normally.

- Josh

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message