forked from systemjs/systemjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (38 loc) · 1.68 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
if (typeof Promise === 'undefined')
require('when/es6-shim/Promise');
if (typeof URL === 'undefined')
require('es6-module-loader/src/url-polyfill');
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;
function configNodePath(loader, module, nodeModule, wildcard) {
if (loader.paths[module])
return;
var ext = wildcard ? '/package.json' : '';
try {
var match = nodeResolver(nodeModule + ext).replace(/\\/g, '/');
}
catch(e) {}
if (match)
loader.paths[module] = 'file://' + (isWindows ? '/' : '') + match.substr(0, match.length - ext.length) + (wildcard ? '/*.js' : '');
}
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');
configNodePath(this, 'babel-runtime/*', 'babel-runtime', true);
}
}
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;