BAM Weblog

Roy - Modules in master

Brian McKenna2012-03-18

I have just merged the modules branch of Roy into master. I've been implementing this feature since December and have finally got it working mostly the way I wanted.

Roy modules work for node.js:

import "./structural"
console.log (structural.obj.x + structural.obj.y)
let hundred = 100
export hundred

Which compiles to:

var structural = require("./structural");
console.log((structural.obj.x + structural.obj.y));
var hundred = 100;
exports["hundred"] = hundred;;

Roy modules also work in the browser:

// Roy modules have a descriptor format.
// The demo site manually supplies the 'dom' descriptor.

import "dom"

let button = document.getElementById "jsrun"

console.log (button.getAttribute "value")

Which compiles to:

(function() {
// Roy modules have a descriptor format.
// The demo site manually supplies the 'dom' descriptor.
// Using browser module: "dom"
var button = document.getElementById("jsrun");
console.log((button.getAttribute("value")));
})();
Please enable JavaScript to view the comments powered by Disqus.