Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Commit d98a321

Browse files
committed
0.13.0
1 parent d07fb0b commit d98a321

8 files changed

+53
-103
lines changed

bower.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

dist/es6-module-loader-sans-promises.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader-sans-promises.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader-sans-promises.src.js

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,7 @@ function logloads(loads) {
287287

288288
// instead of load.kind, use load.isDeclarative
289289
load.isDeclarative = true;
290-
// parse sets load.declare, load.depsList
291-
loader.loaderObj.parse(load);
290+
__eval(loader.loaderObj.transpile(load), __global, load);
292291
}
293292
else if (typeof instantiateResult == 'object') {
294293
load.depsList = instantiateResult.deps || [];
@@ -1083,9 +1082,6 @@ function logloads(loads) {
10831082
translate: function(load) {
10841083
return load.source;
10851084
},
1086-
parse: function(load) {
1087-
throw new TypeError('Loader.parse is not implemented');
1088-
},
10891085
// 26.3.3.18.5
10901086
instantiate: function(load) {
10911087
}
@@ -1104,47 +1100,42 @@ function logloads(loads) {
11041100
})();
11051101

11061102
/*
1107-
* Traceur and 6to5 Parsing Code for Loader
1103+
* Traceur and 6to5 transpile hook for Loader
11081104
*/
11091105
(function(Loader) {
1110-
// parse function is used to parse a load record
11111106
// Returns an array of ModuleSpecifiers
1112-
var parser, parserModule, parserName, parserOptionsName;
1107+
var transpiler, transpilerModule;
1108+
var isNode = typeof window == 'undefined' && typeof WorkerGlobalScope == 'undefined';
11131109

11141110
// use Traceur by default
1115-
Loader.prototype.parser = 'traceur';
1116-
1117-
Loader.prototype.parse = function(load) {
1118-
if (!parser) {
1119-
parserName = this.parser == '6to5' ? 'to5' : this.parser;
1111+
Loader.prototype.transpiler = 'traceur';
11201112

1121-
// try to pick up parser from global or require
1122-
if (typeof window == 'undefined' && typeof WorkerGlobalScope == 'undefined')
1123-
parserModule = require(this.parser);
1124-
else
1125-
parserModule = __global[parserName];
1113+
Loader.prototype.transpile = function(load) {
1114+
if (!transpiler) {
1115+
if (this.transpiler == '6to5') {
1116+
transpiler = to5Transpile;
1117+
transpilerModule = isNode ? require('6to5-core') : __global.to5;
1118+
}
1119+
else {
1120+
transpiler = traceurTranspile;
1121+
transpilerModule = isNode ? require('traceur') : __global.traceur;
1122+
}
11261123

1127-
if (!parserModule)
1128-
throw new TypeError('Include Traceur or 6to5 for module syntax support');
1129-
1130-
parser = this.parser == '6to5' ? to5Parse : traceurParse;
1124+
if (!transpilerModule)
1125+
throw new TypeError('Include Traceur or 6to5 for module syntax support.');
11311126
}
11321127

1133-
var source = parser.call(this, load);
1134-
1135-
source = 'var __moduleAddress = "' + load.address + '";' + source;
1136-
1137-
__eval(source, __global, load);
1128+
return 'var __moduleAddress = "' + load.address + '";' + transpiler.call(this, load);
11381129
}
11391130

1140-
function traceurParse(load) {
1131+
function traceurTranspile(load) {
11411132
var options = this.traceurOptions || {};
11421133
options.modules = 'instantiate';
11431134
options.script = false;
11441135
options.sourceMaps = 'inline';
11451136
options.filename = load.address;
11461137

1147-
var compiler = new parserModule.Compiler(options);
1138+
var compiler = new transpilerModule.Compiler(options);
11481139
var source = doTraceurCompile(load.source, compiler, options.filename);
11491140

11501141
// add "!eval" to end of Traceur sourceURL
@@ -1163,15 +1154,15 @@ function logloads(loads) {
11631154
}
11641155
}
11651156

1166-
function to5Parse(load) {
1157+
function to5Transpile(load) {
11671158
var options = this.to5Options || {};
11681159
options.modules = 'system';
11691160
options.sourceMap = 'inline';
11701161
options.filename = load.address;
11711162
options.code = true;
11721163
options.ast = false;
11731164

1174-
var source = parserModule.transform(load.source, options).code;
1165+
var source = transpilerModule.transform(load.source, options).code;
11751166

11761167
// add "!eval" to end of 6to5 sourceURL
11771168
// I believe this does something?

dist/es6-module-loader.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/es6-module-loader.src.js

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,8 +1512,7 @@ function logloads(loads) {
15121512

15131513
// instead of load.kind, use load.isDeclarative
15141514
load.isDeclarative = true;
1515-
// parse sets load.declare, load.depsList
1516-
loader.loaderObj.parse(load);
1515+
__eval(loader.loaderObj.transpile(load), __global, load);
15171516
}
15181517
else if (typeof instantiateResult == 'object') {
15191518
load.depsList = instantiateResult.deps || [];
@@ -2308,9 +2307,6 @@ function logloads(loads) {
23082307
translate: function(load) {
23092308
return load.source;
23102309
},
2311-
parse: function(load) {
2312-
throw new TypeError('Loader.parse is not implemented');
2313-
},
23142310
// 26.3.3.18.5
23152311
instantiate: function(load) {
23162312
}
@@ -2329,47 +2325,42 @@ function logloads(loads) {
23292325
})();
23302326

23312327
/*
2332-
* Traceur and 6to5 Parsing Code for Loader
2328+
* Traceur and 6to5 transpile hook for Loader
23332329
*/
23342330
(function(Loader) {
2335-
// parse function is used to parse a load record
23362331
// Returns an array of ModuleSpecifiers
2337-
var parser, parserModule, parserName, parserOptionsName;
2332+
var transpiler, transpilerModule;
2333+
var isNode = typeof window == 'undefined' && typeof WorkerGlobalScope == 'undefined';
23382334

23392335
// use Traceur by default
2340-
Loader.prototype.parser = 'traceur';
2341-
2342-
Loader.prototype.parse = function(load) {
2343-
if (!parser) {
2344-
parserName = this.parser == '6to5' ? 'to5' : this.parser;
2336+
Loader.prototype.transpiler = 'traceur';
23452337

2346-
// try to pick up parser from global or require
2347-
if (typeof window == 'undefined' && typeof WorkerGlobalScope == 'undefined')
2348-
parserModule = require(this.parser);
2349-
else
2350-
parserModule = __global[parserName];
2338+
Loader.prototype.transpile = function(load) {
2339+
if (!transpiler) {
2340+
if (this.transpiler == '6to5') {
2341+
transpiler = to5Transpile;
2342+
transpilerModule = isNode ? require('6to5-core') : __global.to5;
2343+
}
2344+
else {
2345+
transpiler = traceurTranspile;
2346+
transpilerModule = isNode ? require('traceur') : __global.traceur;
2347+
}
23512348

2352-
if (!parserModule)
2353-
throw new TypeError('Include Traceur or 6to5 for module syntax support');
2354-
2355-
parser = this.parser == '6to5' ? to5Parse : traceurParse;
2349+
if (!transpilerModule)
2350+
throw new TypeError('Include Traceur or 6to5 for module syntax support.');
23562351
}
23572352

2358-
var source = parser.call(this, load);
2359-
2360-
source = 'var __moduleAddress = "' + load.address + '";' + source;
2361-
2362-
__eval(source, __global, load);
2353+
return 'var __moduleAddress = "' + load.address + '";' + transpiler.call(this, load);
23632354
}
23642355

2365-
function traceurParse(load) {
2356+
function traceurTranspile(load) {
23662357
var options = this.traceurOptions || {};
23672358
options.modules = 'instantiate';
23682359
options.script = false;
23692360
options.sourceMaps = 'inline';
23702361
options.filename = load.address;
23712362

2372-
var compiler = new parserModule.Compiler(options);
2363+
var compiler = new transpilerModule.Compiler(options);
23732364
var source = doTraceurCompile(load.source, compiler, options.filename);
23742365

23752366
// add "!eval" to end of Traceur sourceURL
@@ -2388,15 +2379,15 @@ function logloads(loads) {
23882379
}
23892380
}
23902381

2391-
function to5Parse(load) {
2382+
function to5Transpile(load) {
23922383
var options = this.to5Options || {};
23932384
options.modules = 'system';
23942385
options.sourceMap = 'inline';
23952386
options.filename = load.address;
23962387
options.code = true;
23972388
options.ast = false;
23982389

2399-
var source = parserModule.transform(load.source, options).code;
2390+
var source = transpilerModule.transform(load.source, options).code;
24002391

24012392
// add "!eval" to end of 6to5 sourceURL
24022393
// I believe this does something?

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "es6-module-loader",
33
"description": "An ES6 Module Loader shim",
4-
"version": "0.12.0",
4+
"version": "0.13.0",
55
"homepage": "https://github.com/ModuleLoader/es6-module-loader",
66
"author": {
77
"name": "Guy Bedford, Luke Hoban, Addy Osmani",
@@ -63,9 +63,9 @@
6363
"test:browser:perf": "karma start karma-benchmark.conf.js --single-run"
6464
},
6565
"dependencies": {
66-
"6to5-core": "~3.3.1",
66+
"6to5-core": "~3.3.2",
6767
"grunt-contrib-uglify": "0.6.0",
6868
"traceur": "0.0.82",
69-
"when": "^3.6.4"
69+
"when": "^3.7.2"
7070
}
7171
}

0 commit comments

Comments
 (0)