2016-10-10 03:43:44 +02:00
|
|
|
if (typeof Promise === 'undefined')
|
|
|
|
require('when/es6-shim/Promise');
|
|
|
|
|
|
|
|
var version = require('./package.json').version;
|
|
|
|
|
|
|
|
var isWindows = typeof process.platform != 'undefined' && process.platform.match(/^win/);
|
|
|
|
|
|
|
|
// set transpiler paths in Node
|
|
|
|
var nodeResolver = typeof process != 'undefined' && typeof require != 'undefined' && require.resolve;
|
2017-04-20 03:09:25 +02:00
|
|
|
function configNodePath(loader, module, nodeModule) {
|
2016-10-10 03:43:44 +02:00
|
|
|
if (loader.paths[module])
|
|
|
|
return;
|
|
|
|
|
|
|
|
try {
|
2017-04-20 03:09:25 +02:00
|
|
|
var match = nodeResolver(nodeModule + (module[module.length - 1] === '/' ? 'package.json' : '')).replace(/\\/g, '/');
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
catch(e) {}
|
2017-04-20 03:09:25 +02:00
|
|
|
|
2016-10-10 03:43:44 +02:00
|
|
|
if (match)
|
2017-04-20 03:09:25 +02:00
|
|
|
loader.paths[module] = 'file://' + (isWindows ? '/' : '') + match.substr(0, match.length - (module[module.length - 1] === '/' ? 12 : 0));
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var SystemJSLoader = require('./dist/system.src').constructor;
|
|
|
|
|
|
|
|
// standard class extend SystemJSLoader to SystemJSNodeLoader
|
|
|
|
function SystemJSNodeLoader() {
|
|
|
|
SystemJSLoader.call(this);
|
|
|
|
|
|
|
|
if (nodeResolver) {
|
|
|
|
configNodePath(this, 'traceur', 'traceur/bin/traceur.js');
|
|
|
|
configNodePath(this, 'traceur-runtime', 'traceur/bin/traceur-runtime.js');
|
|
|
|
configNodePath(this, 'babel', 'babel-core/browser.js');
|
|
|
|
configNodePath(this, 'babel/external-helpers', 'babel-core/external-helpers.js');
|
2017-04-20 03:09:25 +02:00
|
|
|
configNodePath(this, 'babel-runtime/', 'babel-runtime/');
|
2016-10-10 03:43:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SystemJSNodeLoader.prototype = Object.create(SystemJSLoader.prototype);
|
|
|
|
SystemJSNodeLoader.prototype.constructor = SystemJSNodeLoader;
|
|
|
|
|
|
|
|
var System = new SystemJSNodeLoader();
|
|
|
|
|
|
|
|
System.version = version + ' Node';
|
|
|
|
|
|
|
|
if (typeof global != 'undefined')
|
|
|
|
global.System = global.SystemJS = System;
|
|
|
|
|
|
|
|
module.exports = System;
|