UNPKG

664 BJavaScriptView Raw
1var fs = require('fs'),
2 path = require('path'),
3 traceurPath = require.resolve('traceur'),
4 makeNode = require("../node/make_node"),
5 minify = require("../graph/minify");
6
7module.exports = function(bundle){
8 var lastTraceur = traceurPath.indexOf("traceur" + path.sep);
9 var baseTraceur = traceurPath.substr(0, lastTraceur);
10
11 // We have to product Steal's system.
12
13 var traceurRuntime = fs.readFileSync( path.join(baseTraceur,"traceur/bin/traceur-runtime.js") );
14
15 var node = makeNode("[traceur-runtime]", "this._System = this.System;\n"+traceurRuntime+";\nthis.System = this._System; delete this._System");
16 minify([node]);
17 bundle.nodes.unshift( node );
18};