es6_module_transpiler-rails 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +5 -0
- data/es6_module_transpiler-rails.gemspec +1 -1
- data/lib/es6_module_transpiler/rails/version.rb +1 -1
- data/lib/es6_module_transpiler/support/es6-module-transpiler.js +250 -51
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef492949c9891aea4037b153ed175704b51664a0
|
4
|
+
data.tar.gz: dfde4e7c2bcda175cfc2c5b499ecb0c726e84e31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8d4a8bc753035f49bb01fc2dcd51207d837eb4c1c88c60c844d1ad306ccaff0e42d48fb7f0a107503460bd5619e0552aa57dfe6e5f33665e590b4b330a68f08
|
7
|
+
data.tar.gz: 60bec7dbbfe15bacf4d7ec02e49013ef3e0f3efe69f1cf5a73dc6ad3983dd13f4aac4ba7ac2a65fc16a039bc0f94606f1c07aa4aa14446e1a37efc583d592924
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -68,6 +68,11 @@ This would match names that start with the pattern and prepend with
|
|
68
68
|
`app/`. For example, `controllers/fooController` would now be named
|
69
69
|
`app/controllers/fooController`.
|
70
70
|
|
71
|
+
Note the path is the *logical path* for the asset. For example, if the
|
72
|
+
path to your asset is
|
73
|
+
`app/assets/javascripts/controllers/fooController.js.es6` the logical
|
74
|
+
path is `controllers/fooController`.
|
75
|
+
|
71
76
|
## Authors ##
|
72
77
|
|
73
78
|
[Brian Cardarella](http://twitter.com/bcardarella)
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Brian Cardarella"]
|
10
10
|
spec.email = ["bcardarella@gmail.com"]
|
11
11
|
spec.summary = %q{ES6 Module Transpiler for Rails}
|
12
|
-
spec.description = %q{Compile ES6
|
12
|
+
spec.description = %q{Compile ES6 modules in the asset pipeline}
|
13
13
|
spec.homepage = "https://github.com/dockyard/es6_module_transpiler-rails"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -538,8 +538,7 @@
|
|
538
538
|
|
539
539
|
})(typeof global !== 'undefined' ? global : this);
|
540
540
|
|
541
|
-
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.ModuleTranspiler=e():"undefined"!=typeof global?global.ModuleTranspiler=e():"undefined"!=typeof self&&(self.ModuleTranspiler=e())}(function(){var define,module,exports;
|
542
|
-
return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
541
|
+
!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.ModuleTranspiler=e():"undefined"!=typeof global?global.ModuleTranspiler=e():"undefined"!=typeof self&&(self.ModuleTranspiler=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
543
542
|
/*
|
544
543
|
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
|
545
544
|
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
|
@@ -729,7 +728,7 @@ parseYieldExpression: true
|
|
729
728
|
};
|
730
729
|
|
731
730
|
ClassPropertyType = {
|
732
|
-
static: 'static',
|
731
|
+
'static': 'static',
|
733
732
|
prototype: 'prototype'
|
734
733
|
};
|
735
734
|
|
@@ -3013,13 +3012,9 @@ parseYieldExpression: true
|
|
3013
3012
|
|
3014
3013
|
++state.parenthesizedCount;
|
3015
3014
|
|
3016
|
-
state.allowArrowFunction = !state.allowArrowFunction;
|
3017
3015
|
expr = parseExpression();
|
3018
|
-
state.allowArrowFunction = false;
|
3019
3016
|
|
3020
|
-
|
3021
|
-
expect(')');
|
3022
|
-
}
|
3017
|
+
expect(')');
|
3023
3018
|
|
3024
3019
|
return expr;
|
3025
3020
|
}
|
@@ -3529,23 +3524,31 @@ parseYieldExpression: true
|
|
3529
3524
|
params.push(param.left);
|
3530
3525
|
defaults.push(param.right);
|
3531
3526
|
++defaultCount;
|
3527
|
+
validateParam(options, param.left, param.left.name);
|
3532
3528
|
} else {
|
3533
3529
|
return null;
|
3534
3530
|
}
|
3535
3531
|
}
|
3536
3532
|
|
3537
|
-
if (options.
|
3538
|
-
throwError(
|
3539
|
-
|
3540
|
-
|
3541
|
-
|
3533
|
+
if (options.message === Messages.StrictParamDupe) {
|
3534
|
+
throwError(
|
3535
|
+
strict ? options.stricted : options.firstRestricted,
|
3536
|
+
options.message
|
3537
|
+
);
|
3542
3538
|
}
|
3543
3539
|
|
3544
3540
|
if (defaultCount === 0) {
|
3545
3541
|
defaults = [];
|
3546
3542
|
}
|
3547
3543
|
|
3548
|
-
return {
|
3544
|
+
return {
|
3545
|
+
params: params,
|
3546
|
+
defaults: defaults,
|
3547
|
+
rest: rest,
|
3548
|
+
stricted: options.stricted,
|
3549
|
+
firstRestricted: options.firstRestricted,
|
3550
|
+
message: options.message
|
3551
|
+
};
|
3549
3552
|
}
|
3550
3553
|
|
3551
3554
|
function parseArrowFunctionExpression(options) {
|
@@ -3555,9 +3558,16 @@ parseYieldExpression: true
|
|
3555
3558
|
|
3556
3559
|
previousStrict = strict;
|
3557
3560
|
previousYieldAllowed = state.yieldAllowed;
|
3558
|
-
strict = true;
|
3559
3561
|
state.yieldAllowed = false;
|
3560
3562
|
body = parseConciseBody();
|
3563
|
+
|
3564
|
+
if (strict && options.firstRestricted) {
|
3565
|
+
throwError(options.firstRestricted, options.message);
|
3566
|
+
}
|
3567
|
+
if (strict && options.stricted) {
|
3568
|
+
throwErrorTolerant(options.stricted, options.message);
|
3569
|
+
}
|
3570
|
+
|
3561
3571
|
strict = previousStrict;
|
3562
3572
|
state.yieldAllowed = previousYieldAllowed;
|
3563
3573
|
|
@@ -3587,12 +3597,16 @@ parseYieldExpression: true
|
|
3587
3597
|
token = lookahead;
|
3588
3598
|
expr = parseConditionalExpression();
|
3589
3599
|
|
3590
|
-
if (match('=>') &&
|
3591
|
-
|
3592
|
-
|
3593
|
-
|
3594
|
-
|
3595
|
-
|
3600
|
+
if (match('=>') &&
|
3601
|
+
(state.parenthesizedCount === oldParenthesizedCount ||
|
3602
|
+
state.parenthesizedCount === (oldParenthesizedCount + 1))) {
|
3603
|
+
if (expr.type === Syntax.Identifier) {
|
3604
|
+
params = reinterpretAsCoverFormalsList([ expr ]);
|
3605
|
+
} else if (expr.type === Syntax.SequenceExpression) {
|
3606
|
+
params = reinterpretAsCoverFormalsList(expr.expressions);
|
3607
|
+
}
|
3608
|
+
if (params) {
|
3609
|
+
return parseArrowFunctionExpression(params);
|
3596
3610
|
}
|
3597
3611
|
}
|
3598
3612
|
|
@@ -3618,7 +3632,9 @@ parseYieldExpression: true
|
|
3618
3632
|
// 11.14 Comma Operator
|
3619
3633
|
|
3620
3634
|
function parseExpression() {
|
3621
|
-
var expr, expressions, sequence, coverFormalsList, spreadFound,
|
3635
|
+
var expr, expressions, sequence, coverFormalsList, spreadFound, oldParenthesizedCount;
|
3636
|
+
|
3637
|
+
oldParenthesizedCount = state.parenthesizedCount;
|
3622
3638
|
|
3623
3639
|
expr = parseAssignmentExpression();
|
3624
3640
|
expressions = [ expr ];
|
@@ -3645,23 +3661,19 @@ parseYieldExpression: true
|
|
3645
3661
|
sequence = delegate.createSequenceExpression(expressions);
|
3646
3662
|
}
|
3647
3663
|
|
3648
|
-
if (
|
3649
|
-
|
3650
|
-
if (
|
3651
|
-
|
3652
|
-
|
3653
|
-
state.allowArrowFunction = false;
|
3654
|
-
expr = expressions;
|
3664
|
+
if (match('=>')) {
|
3665
|
+
// Do not allow nested parentheses on the LHS of the =>.
|
3666
|
+
if (state.parenthesizedCount === oldParenthesizedCount || state.parenthesizedCount === (oldParenthesizedCount + 1)) {
|
3667
|
+
expr = expr.type === Syntax.SequenceExpression ? expr.expressions : expressions;
|
3655
3668
|
coverFormalsList = reinterpretAsCoverFormalsList(expr);
|
3656
3669
|
if (coverFormalsList) {
|
3657
3670
|
return parseArrowFunctionExpression(coverFormalsList);
|
3658
3671
|
}
|
3659
|
-
|
3660
|
-
throwUnexpected(token);
|
3661
3672
|
}
|
3673
|
+
throwUnexpected(lex());
|
3662
3674
|
}
|
3663
3675
|
|
3664
|
-
if (spreadFound) {
|
3676
|
+
if (spreadFound && lookahead2().value !== '=>') {
|
3665
3677
|
throwError({}, Messages.IllegalSpread);
|
3666
3678
|
}
|
3667
3679
|
|
@@ -5506,19 +5518,11 @@ parseYieldExpression: true
|
|
5506
5518
|
expect('(');
|
5507
5519
|
|
5508
5520
|
++state.parenthesizedCount;
|
5509
|
-
|
5510
|
-
state.allowArrowFunction = !state.allowArrowFunction;
|
5511
5521
|
expr = parseExpression();
|
5512
|
-
state.allowArrowFunction = false;
|
5513
5522
|
|
5514
|
-
|
5515
|
-
|
5516
|
-
|
5517
|
-
} else {
|
5518
|
-
expect(')');
|
5519
|
-
marker.end();
|
5520
|
-
marker.applyGroup(expr);
|
5521
|
-
}
|
5523
|
+
expect(')');
|
5524
|
+
marker.end();
|
5525
|
+
marker.applyGroup(expr);
|
5522
5526
|
|
5523
5527
|
return expr;
|
5524
5528
|
}
|
@@ -6391,6 +6395,11 @@ var $__superDescriptor = function(proto, name) {
|
|
6391
6395
|
};
|
6392
6396
|
var AbstractCompiler = require("./abstract_compiler");
|
6393
6397
|
var SourceModifier = require("./source_modifier");
|
6398
|
+
var string = require("./utils").string;
|
6399
|
+
var SAFE_WARN_NAME = "__es6_transpiler_warn__";
|
6400
|
+
var SAFE_WARN_SOURCE = string.ltrim(string.unindent(("\n function " + SAFE_WARN_NAME + "(warning) {\n if (typeof console === 'undefined') {\n } else if (typeof console.warn === \"function\") {\n console.warn(warning);\n } else if (typeof console.log === \"function\") {\n console.log(warning);\n }\n }")));
|
6401
|
+
var MODULE_OBJECT_BUILDER_NAME = "__es6_transpiler_build_module_object__";
|
6402
|
+
var MODULE_OBJECT_BUILDER_SOURCE = string.ltrim(string.unindent(("\n function " + MODULE_OBJECT_BUILDER_NAME + "(name, imported) {\n var moduleInstanceObject = Object.create ? Object.create(null) : {};\n if (typeof imported === \"function\") {\n " + SAFE_WARN_NAME + "(\"imported module '\"+name+\"' exported a function - this may not work as expected\");\n }\n for (var key in imported) {\n if (Object.prototype.hasOwnProperty.call(imported, key)) {\n moduleInstanceObject[key] = imported[key];\n }\n }\n if (Object.freeze) {\n Object.freeze(moduleInstanceObject);\n }\n return moduleInstanceObject;\n }")));
|
6394
6403
|
var CJSCompiler = function($__super) {
|
6395
6404
|
'use strict';
|
6396
6405
|
var $__proto = $__getProtoParent($__super);
|
@@ -6401,15 +6410,43 @@ var CJSCompiler = function($__super) {
|
|
6401
6410
|
stringify: function() {
|
6402
6411
|
var string = this.string.toString();
|
6403
6412
|
this.source = new SourceModifier(string);
|
6413
|
+
this.prelude = [];
|
6404
6414
|
this.buildImports();
|
6405
6415
|
this.buildExports();
|
6406
6416
|
var out = "\"use strict\";\n";
|
6417
|
+
{
|
6418
|
+
var $__1 = traceur.runtime.getIterator(this.prelude);
|
6419
|
+
try {
|
6420
|
+
while (true) {
|
6421
|
+
var source = $__1.next();
|
6422
|
+
{
|
6423
|
+
out += source + "\n";
|
6424
|
+
}
|
6425
|
+
}
|
6426
|
+
} catch (e) {
|
6427
|
+
if (!traceur.runtime.isStopIteration(e)) throw e;
|
6428
|
+
}
|
6429
|
+
}
|
6407
6430
|
out += this.source.toString();
|
6408
6431
|
out = out.trim();
|
6409
6432
|
return out;
|
6410
6433
|
},
|
6411
6434
|
doModuleImport: function(name, dependencyName, idx) {
|
6412
|
-
|
6435
|
+
this.ensureHasModuleObjectBuilder();
|
6436
|
+
return ("var " + name + " = " + MODULE_OBJECT_BUILDER_NAME + "(\"" + name + "\", require(\"" + name + "\"));\n");
|
6437
|
+
},
|
6438
|
+
ensureHasModuleObjectBuilder: function() {
|
6439
|
+
this.ensureHasSafeWarn();
|
6440
|
+
this.ensureInPrelude(MODULE_OBJECT_BUILDER_NAME, MODULE_OBJECT_BUILDER_SOURCE);
|
6441
|
+
},
|
6442
|
+
ensureHasSafeWarn: function() {
|
6443
|
+
this.ensureInPrelude(SAFE_WARN_NAME, SAFE_WARN_SOURCE);
|
6444
|
+
},
|
6445
|
+
ensureInPrelude: function(name, source) {
|
6446
|
+
if (!this.prelude[name]) {
|
6447
|
+
this.prelude[name] = true;
|
6448
|
+
this.prelude.push(source);
|
6449
|
+
}
|
6413
6450
|
},
|
6414
6451
|
doBareImport: function(name) {
|
6415
6452
|
return ("require(\"" + name + "\");");
|
@@ -6440,10 +6477,10 @@ var CJSCompiler = function($__super) {
|
|
6440
6477
|
var dependencyName = import_.source.value;
|
6441
6478
|
var replacement = "";
|
6442
6479
|
{
|
6443
|
-
var $
|
6480
|
+
var $__2 = traceur.runtime.getIterator(import_.specifiers);
|
6444
6481
|
try {
|
6445
6482
|
while (true) {
|
6446
|
-
var specifier = $
|
6483
|
+
var specifier = $__2.next();
|
6447
6484
|
{
|
6448
6485
|
var alias = specifier.name ? specifier.name.name: specifier.id.name;
|
6449
6486
|
replacement += this.doNamedImport(specifier.id.name, dependencyName, alias);
|
@@ -6461,7 +6498,7 @@ var CJSCompiler = function($__super) {
|
|
6461
6498
|
module.exports = CJSCompiler;
|
6462
6499
|
|
6463
6500
|
|
6464
|
-
},{"./abstract_compiler":2,"./source_modifier":10}],5:[function(require,module,exports){
|
6501
|
+
},{"./abstract_compiler":2,"./source_modifier":10,"./utils":11}],5:[function(require,module,exports){
|
6465
6502
|
"use strict";
|
6466
6503
|
var $__superDescriptor = function(proto, name) {
|
6467
6504
|
if (!proto) throw new TypeError('super is null');
|
@@ -6525,6 +6562,7 @@ var $__getDescriptors = function(object) {
|
|
6525
6562
|
return ctor;
|
6526
6563
|
};
|
6527
6564
|
var AMDCompiler = require("./amd_compiler");
|
6565
|
+
var YUICompiler = require("./yui_compiler");
|
6528
6566
|
var CJSCompiler = require("./cjs_compiler");
|
6529
6567
|
var GlobalsCompiler = require("./globals_compiler");
|
6530
6568
|
var Parser = require("./parser");
|
@@ -6556,6 +6594,9 @@ var Compiler = function() {
|
|
6556
6594
|
toAMD: function() {
|
6557
6595
|
return new AMDCompiler(this, this.options).stringify();
|
6558
6596
|
},
|
6597
|
+
toYUI: function() {
|
6598
|
+
return new YUICompiler(this, this.options).stringify();
|
6599
|
+
},
|
6559
6600
|
toCJS: function() {
|
6560
6601
|
return new CJSCompiler(this, this.options).stringify();
|
6561
6602
|
},
|
@@ -6568,7 +6609,7 @@ var Compiler = function() {
|
|
6568
6609
|
module.exports = Compiler;
|
6569
6610
|
|
6570
6611
|
|
6571
|
-
},{"./amd_compiler":3,"./cjs_compiler":4,"./globals_compiler":7,"./parser":9,"./utils":11}],7:[function(require,module,exports){
|
6612
|
+
},{"./amd_compiler":3,"./cjs_compiler":4,"./globals_compiler":7,"./parser":9,"./utils":11,"./yui_compiler":12}],7:[function(require,module,exports){
|
6572
6613
|
"use strict";
|
6573
6614
|
var $__superDescriptor = function(proto, name) {
|
6574
6615
|
if (!proto) throw new TypeError('super is null');
|
@@ -6724,18 +6765,20 @@ module.exports = GlobalsCompiler;
|
|
6724
6765
|
var Compiler = require("./compiler");
|
6725
6766
|
var AbstractCompiler = require("./abstract_compiler");
|
6726
6767
|
var AmdCompiler = require("./amd_compiler");
|
6768
|
+
var YuiCompiler = require("./yui_compiler");
|
6727
6769
|
var CjsCompiler = require("./cjs_compiler");
|
6728
6770
|
var GlobalsCompiler = require("./globals_compiler");
|
6729
6771
|
var SourceModifier = require("./source_modifier");
|
6730
6772
|
exports.Compiler = Compiler;
|
6731
6773
|
exports.AbstractCompiler = AbstractCompiler;
|
6732
6774
|
exports.AmdCompiler = AmdCompiler;
|
6775
|
+
exports.YuiCompiler = YuiCompiler;
|
6733
6776
|
exports.CjsCompiler = CjsCompiler;
|
6734
6777
|
exports.GlobalsCompiler = GlobalsCompiler;
|
6735
6778
|
exports.SourceModifier = SourceModifier;
|
6736
6779
|
|
6737
6780
|
|
6738
|
-
},{"./abstract_compiler":2,"./amd_compiler":3,"./cjs_compiler":4,"./compiler":6,"./globals_compiler":7,"./source_modifier":10}],9:[function(require,module,exports){
|
6781
|
+
},{"./abstract_compiler":2,"./amd_compiler":3,"./cjs_compiler":4,"./compiler":6,"./globals_compiler":7,"./source_modifier":10,"./yui_compiler":12}],9:[function(require,module,exports){
|
6739
6782
|
"use strict";
|
6740
6783
|
var $__getDescriptors = function(object) {
|
6741
6784
|
var descriptors = {}, name, names = Object.getOwnPropertyNames(object);
|
@@ -6965,7 +7008,45 @@ function indent(lines, level) {
|
|
6965
7008
|
return line;
|
6966
7009
|
});
|
6967
7010
|
}
|
6968
|
-
var
|
7011
|
+
var WHITESPACE_ONLY = /^\s*$/;
|
7012
|
+
var LEADING_WHITESPACE = /^\s*/;
|
7013
|
+
function unindent(string) {
|
7014
|
+
var minIndent = null;
|
7015
|
+
var lines = string.split('\n');
|
7016
|
+
{
|
7017
|
+
var $__1 = traceur.runtime.getIterator(lines);
|
7018
|
+
try {
|
7019
|
+
while (true) {
|
7020
|
+
var line = $__1.next();
|
7021
|
+
{
|
7022
|
+
if (!WHITESPACE_ONLY.test(line)) {
|
7023
|
+
var match = line.match(LEADING_WHITESPACE);
|
7024
|
+
if (match) {
|
7025
|
+
if (minIndent !== null) {
|
7026
|
+
minIndent = Math.min(match[0].length, minIndent);
|
7027
|
+
} else {
|
7028
|
+
minIndent = match[0].length;
|
7029
|
+
}
|
7030
|
+
}
|
7031
|
+
}
|
7032
|
+
}
|
7033
|
+
}
|
7034
|
+
} catch (e) {
|
7035
|
+
if (!traceur.runtime.isStopIteration(e)) throw e;
|
7036
|
+
}
|
7037
|
+
}
|
7038
|
+
return lines.map((function(line) {
|
7039
|
+
return line.slice(minIndent);
|
7040
|
+
})).join('\n');
|
7041
|
+
}
|
7042
|
+
function ltrim(string) {
|
7043
|
+
return string.replace(LEADING_WHITESPACE, '');
|
7044
|
+
}
|
7045
|
+
var string = {
|
7046
|
+
indent: indent,
|
7047
|
+
unindent: unindent,
|
7048
|
+
ltrim: ltrim
|
7049
|
+
};
|
6969
7050
|
var Unique = function() {
|
6970
7051
|
'use strict';
|
6971
7052
|
var $Unique = ($__createClassNoExtends)({
|
@@ -6986,7 +7067,125 @@ exports.forEach = forEach;
|
|
6986
7067
|
exports.string = string;
|
6987
7068
|
|
6988
7069
|
|
6989
|
-
},{}]
|
7070
|
+
},{}],12:[function(require,module,exports){
|
7071
|
+
"use strict";
|
7072
|
+
var $__superDescriptor = function(proto, name) {
|
7073
|
+
if (!proto) throw new TypeError('super is null');
|
7074
|
+
return Object.getPropertyDescriptor(proto, name);
|
7075
|
+
}, $__superCall = function(self, proto, name, args) {
|
7076
|
+
var descriptor = $__superDescriptor(proto, name);
|
7077
|
+
if (descriptor) {
|
7078
|
+
if ('value'in descriptor) return descriptor.value.apply(self, args);
|
7079
|
+
if (descriptor.get) return descriptor.get.call(self).apply(self, args);
|
7080
|
+
}
|
7081
|
+
throw new TypeError("Object has no method '" + name + "'.");
|
7082
|
+
}, $__getProtoParent = function(superClass) {
|
7083
|
+
if (typeof superClass === 'function') {
|
7084
|
+
var prototype = superClass.prototype;
|
7085
|
+
if (Object(prototype) === prototype || prototype === null) return superClass.prototype;
|
7086
|
+
}
|
7087
|
+
if (superClass === null) return null;
|
7088
|
+
throw new TypeError();
|
7089
|
+
}, $__getDescriptors = function(object) {
|
7090
|
+
var descriptors = {}, name, names = Object.getOwnPropertyNames(object);
|
7091
|
+
for (var i = 0; i < names.length; i++) {
|
7092
|
+
var name = names[i];
|
7093
|
+
descriptors[name] = Object.getOwnPropertyDescriptor(object, name);
|
7094
|
+
}
|
7095
|
+
return descriptors;
|
7096
|
+
}, $__createClass = function(object, staticObject, protoParent, superClass, hasConstructor) {
|
7097
|
+
var ctor = object.constructor;
|
7098
|
+
if (typeof superClass === 'function') ctor.__proto__ = superClass;
|
7099
|
+
if (!hasConstructor && protoParent === null) ctor = object.constructor = function() {};
|
7100
|
+
var descriptors = $__getDescriptors(object);
|
7101
|
+
descriptors.constructor.enumerable = false;
|
7102
|
+
ctor.prototype = Object.create(protoParent, descriptors);
|
7103
|
+
Object.defineProperties(ctor, $__getDescriptors(staticObject));
|
7104
|
+
return ctor;
|
7105
|
+
};
|
7106
|
+
var AbstractCompiler = require("./abstract_compiler");
|
7107
|
+
var SourceModifier = require("./source_modifier");
|
7108
|
+
var YUICompiler = function($__super) {
|
7109
|
+
'use strict';
|
7110
|
+
var $__proto = $__getProtoParent($__super);
|
7111
|
+
var $YUICompiler = ($__createClass)({
|
7112
|
+
constructor: function() {
|
7113
|
+
$__superCall(this, $__proto, "constructor", arguments);
|
7114
|
+
},
|
7115
|
+
stringify: function() {
|
7116
|
+
var string = this.string.toString();
|
7117
|
+
this.source = new SourceModifier(string);
|
7118
|
+
var out = this.buildPreamble();
|
7119
|
+
this.buildImports();
|
7120
|
+
this.buildExports();
|
7121
|
+
out += (this.indentLines(" ") + "\n return __exports__;\n}, \"@VERSION@\", " + this.buildMetas() + ");");
|
7122
|
+
return out;
|
7123
|
+
},
|
7124
|
+
buildPreamble: function() {
|
7125
|
+
var name = this.moduleName || "@NAME@";
|
7126
|
+
return ("YUI.add(\"" + name + "\", function(Y, NAME, __imports__, __exports__) {\n \"use strict\";\n");
|
7127
|
+
},
|
7128
|
+
buildMetas: function() {
|
7129
|
+
return JSON.stringify({
|
7130
|
+
es: true,
|
7131
|
+
requires: this.dependencyNames
|
7132
|
+
});
|
7133
|
+
},
|
7134
|
+
doModuleImport: function(name, dependencyName, idx) {
|
7135
|
+
return ("var " + name + " = __imports__[\"" + dependencyName + "\"];\n");
|
7136
|
+
},
|
7137
|
+
doBareImport: function(name) {
|
7138
|
+
return "";
|
7139
|
+
},
|
7140
|
+
doDefaultImport: function(name, dependencyName, idx) {
|
7141
|
+
if (this.options.compatFix === true) {
|
7142
|
+
return ("var " + name + " = __imports__[\"" + dependencyName + "\"][\"default\"] || __imports__[\"" + dependencyName + "\"];\n");
|
7143
|
+
} else {
|
7144
|
+
return ("var " + name + " = __imports__[\"" + dependencyName + "\"][\"default\"];\n");
|
7145
|
+
}
|
7146
|
+
},
|
7147
|
+
doNamedImport: function(name, dependencyName, alias) {
|
7148
|
+
var member = (name === 'default' ? '["default"]': '.' + name);
|
7149
|
+
return ("var " + alias + " = __imports__[\"" + dependencyName + "\"]" + member + ";\n");
|
7150
|
+
},
|
7151
|
+
doExportSpecifier: function(name, reexport) {
|
7152
|
+
if (reexport) {
|
7153
|
+
return ("__exports__." + name + " = __imports__[\"" + reexport + "\"]." + name + ";\n");
|
7154
|
+
}
|
7155
|
+
return ("__exports__." + name + " = " + name + ";\n");
|
7156
|
+
},
|
7157
|
+
doExportDeclaration: function(name) {
|
7158
|
+
return ("\n__exports__." + name + " = " + name + ";");
|
7159
|
+
},
|
7160
|
+
doDefaultExport: function() {
|
7161
|
+
return "__exports__[\"default\"] = ";
|
7162
|
+
},
|
7163
|
+
doImportSpecifiers: function(import_, idx) {
|
7164
|
+
var dependencyName = import_.source.value;
|
7165
|
+
var replacement = "";
|
7166
|
+
{
|
7167
|
+
var $__1 = traceur.runtime.getIterator(import_.specifiers);
|
7168
|
+
try {
|
7169
|
+
while (true) {
|
7170
|
+
var specifier = $__1.next();
|
7171
|
+
{
|
7172
|
+
var alias = specifier.name ? specifier.name.name: specifier.id.name;
|
7173
|
+
replacement += this.doNamedImport(specifier.id.name, dependencyName, alias);
|
7174
|
+
}
|
7175
|
+
}
|
7176
|
+
} catch (e) {
|
7177
|
+
if (!traceur.runtime.isStopIteration(e)) throw e;
|
7178
|
+
}
|
7179
|
+
}
|
7180
|
+
return replacement;
|
7181
|
+
}
|
7182
|
+
}, {}, $__proto, $__super, false);
|
7183
|
+
return $YUICompiler;
|
7184
|
+
}(AbstractCompiler);
|
7185
|
+
module.exports = YUICompiler;
|
7186
|
+
|
7187
|
+
|
7188
|
+
},{"./abstract_compiler":2,"./source_modifier":10}]},{},[8])
|
6990
7189
|
(8)
|
6991
7190
|
});
|
6992
7191
|
;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es6_module_transpiler-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cardarella
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execjs
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: Compile ES6
|
69
|
+
description: Compile ES6 modules in the asset pipeline
|
70
70
|
email:
|
71
71
|
- bcardarella@gmail.com
|
72
72
|
executables: []
|
@@ -74,6 +74,7 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- .gitignore
|
77
|
+
- CHANGELOG.md
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
111
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.0.3
|
112
113
|
signing_key:
|
113
114
|
specification_version: 4
|
114
115
|
summary: ES6 Module Transpiler for Rails
|