As much as I love this way of importing scope it is no longer viable in
modern JavaScript. So you won't be able to do this in version 2.0.
Here is the new way of namespacing in base2. It's not as pretty but it
works just as well:
base2.exec(function(_) {
var numbers = [1,2,4];
var squares = _.map(numbers, function(value) {
return value * value;
});
});
base2.require("dom,io", function(_, dom, io) {
var fs = new io.LocalFileSystem("/docs");
var externals = dom.querySelectorAll(document, "script[src]");
});
The first namespace (in this case "_") amalgamates all of the *required*
namespaces, so this the following is equivalent to the above code:
base2.require("dom,io", function(_, dom, io) {
var fs = new _.LocalFileSystem("/docs");
var externals = _.querySelectorAll(document, "script[src]");
});
That's probably not very clear but it's just a heads up that the
packaging/namespacing is very different in version 2.0.
-dean
PS. It's easy for Packer (or any compressor) to convert
"_.querySelectorAll" into a static variable in a closure. That means
better compression ratios and better performing code.