Commit f358d910 authored by Brian Donovan's avatar Brian Donovan

Switch to ES6 Module Transpiler from js_module_transpiler.

parent 7a5493c2
# A sample Gemfile
source "https://rubygems.org" source "https://rubygems.org"
gem "js_module_transpiler", github: "wycats/js_module_transpiler", branch: "master"
gem "rake" gem "rake"
GIT
remote: git://github.com/wycats/js_module_transpiler.git
revision: c9f0ada0f7b7ec654ddec25f4a1fb07bcf41c9f7
branch: master
specs:
js_module_transpiler (0.0.1)
thor
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
rake (10.0.2) rake (10.0.2)
thor (0.16.0)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
js_module_transpiler!
rake rake
require "bundler/setup" require "bundler/setup"
require "js_module_transpiler"
ENV['PATH'] = "#{Dir.pwd}/node_modules/.bin:#{ENV['PATH']}"
directory "browser" directory "browser"
directory "node_modules/rsvp" directory "node_modules/rsvp"
...@@ -16,9 +17,7 @@ def amd_module(filename) ...@@ -16,9 +17,7 @@ def amd_module(filename)
library = File.read(input) library = File.read(input)
open output, "w" do |file| open output, "w" do |file|
require "js_module_transpiler" file.puts %x{compile-modules --type amd --anonymous -s < #{input}}
converter = JsModuleTranspiler::Compiler.new(library)
file.puts converter.to_amd
end end
end end
...@@ -32,9 +31,7 @@ def node_module(filename, output="node_modules/rsvp/#{filename}.js") ...@@ -32,9 +31,7 @@ def node_module(filename, output="node_modules/rsvp/#{filename}.js")
library = File.read(input) library = File.read(input)
open output, "w" do |file| open output, "w" do |file|
require "js_module_transpiler" file.puts %x{compile-modules --type cjs --anonymous -s < #{input}}
converter = JsModuleTranspiler::Compiler.new(library)
file.puts converter.to_cjs
end end
end end
...@@ -83,7 +80,7 @@ file node_main => ["node_modules/rsvp", node_async, node_events] ...@@ -83,7 +80,7 @@ file node_main => ["node_modules/rsvp", node_async, node_events]
# Minified build # Minified build
file "browser/rsvp.min.js" => "browser/rsvp.js" do file "browser/rsvp.min.js" => "browser/rsvp.js" do
output = `cat browser/rsvp.js | uglifyjs` output = `cat browser/rsvp.js | uglifyjs --mangle`
open "browser/rsvp.min.js", "w" do |file| open "browser/rsvp.min.js", "w" do |file|
file.puts output file.puts output
......
...@@ -48,5 +48,6 @@ define( ...@@ -48,5 +48,6 @@ define(
}; };
} }
__exports__.async = async; __exports__.async = async;
}); });
...@@ -96,5 +96,6 @@ define( ...@@ -96,5 +96,6 @@ define(
} }
}; };
__exports__.EventTarget = EventTarget; __exports__.EventTarget = EventTarget;
}); });
define( define(
["rsvp/async", "rsvp/events", "exports"], ["rsvp/async","rsvp/events","exports"],
function(__dependency1__, __dependency2__, __exports__) { function(__dependency1__, __dependency2__, __exports__) {
"use strict"; "use strict";
var async = __dependency1__.async; var async = __dependency1__.async;
...@@ -166,6 +166,7 @@ define( ...@@ -166,6 +166,7 @@ define(
return deferred; return deferred;
} }
__exports__.Promise = Promise; __exports__.Promise = Promise;
__exports__.all = all; __exports__.all = all;
__exports__.defer = defer; __exports__.defer = defer;
......
...@@ -81,6 +81,7 @@ define("rsvp/async", ...@@ -81,6 +81,7 @@ define("rsvp/async",
}; };
} }
__exports__.async = async; __exports__.async = async;
}); });
...@@ -182,11 +183,12 @@ define("rsvp/events", ...@@ -182,11 +183,12 @@ define("rsvp/events",
} }
}; };
__exports__.EventTarget = EventTarget; __exports__.EventTarget = EventTarget;
}); });
define("rsvp", define("rsvp",
["rsvp/async", "rsvp/events", "exports"], ["rsvp/async","rsvp/events","exports"],
function(__dependency1__, __dependency2__, __exports__) { function(__dependency1__, __dependency2__, __exports__) {
"use strict"; "use strict";
var async = __dependency1__.async; var async = __dependency1__.async;
...@@ -353,6 +355,7 @@ define("rsvp", ...@@ -353,6 +355,7 @@ define("rsvp",
return deferred; return deferred;
} }
__exports__.Promise = Promise; __exports__.Promise = Promise;
__exports__.all = all; __exports__.all = all;
__exports__.defer = defer; __exports__.defer = defer;
......
(function(){var e,t;(function(){var n={},r={};e=function(e,t,r){n[e]={deps:t,callback:r}},t=function(e){if(r[e])return r[e];r[e]={};var i=n[e],s=i.deps,o=i.callback,u=[],a;for(var f=0,l=s.length;f<l;f++)s[f]==="exports"?u.push(a={}):u.push(t(s[f]));var c=o.apply(this,u);return r[e]=a||c}})(),e("rsvp/async",["exports"],function(e){"use strict";var t=typeof window!="undefined"?window:{},n=t.MutationObserver||t.WebKitMutationObserver,r;if(typeof process!="undefined"&&{}.toString.call(process)==="[object process]")r=function(e,t){process.nextTick(function(){e.call(t)})};else if(n){var i=[],s=new n(function(){var e=i.slice();i=[],e.forEach(function(e){var t=e[0],n=e[1];t.call(n)})}),o=document.createElement("div");s.observe(o,{attributes:!0}),window.addEventListener("unload",function(){s.disconnect(),s=null}),r=function(e,t){i.push([e,t]),o.setAttribute("drainQueue","drainQueue")}}else r=function(e,t){setTimeout(function(){e.call(t)},1)};e.async=r}),e("rsvp/events",["exports"],function(e){"use strict";var t=function(e,t){this.type=e;for(var n in t){if(!t.hasOwnProperty(n))continue;this[n]=t[n]}},n=function(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n][0]===t)return n;return-1},r=function(e){var t=e._promiseCallbacks;return t||(t=e._promiseCallbacks={}),t},i={mixin:function(e){return e.on=this.on,e.off=this.off,e.trigger=this.trigger,e},on:function(e,t,i){var s=r(this),o,u;e=e.split(/\s+/),i=i||this;while(u=e.shift())o=s[u],o||(o=s[u]=[]),n(o,t)===-1&&o.push([t,i])},off:function(e,t){var i=r(this),s,o,u;e=e.split(/\s+/);while(o=e.shift()){if(!t){i[o]=[];continue}s=i[o],u=n(s,t),u!==-1&&s.splice(u,1)}},trigger:function(e,n){var i=r(this),s,o,u,a,f;if(s=i[e])for(var l=0;l<s.length;l++)o=s[l],u=o[0],a=o[1],typeof n!="object"&&(n={detail:n}),f=new t(e,n),u.call(a,f)}};e.EventTarget=i}),e("rsvp",["rsvp/async","rsvp/events","exports"],function(e,t,n){"use strict";function f(e,t){s.async(function(){e.trigger("promise:resolved",{detail:t}),e.isFulfilled=!0,e.fulfillmentValue=t})}function l(e,t){s.async(function(){e.trigger("promise:failed",{detail:t}),e.isRejected=!0,e.rejectedReason=t})}function c(e){var t,n=[],r=new u,i=e.length;i===0&&f(r,[]);var s=function(e){return function(t){o(e,t)}},o=function(e,t){n[e]=t,--i===0&&f(r,n)},a=function(e){l(r,e)};for(t=0;t<i;t++)e[t].then(s(t),a);return r}function h(e,t){s[e]=t}function p(){var e={},t=new u(function(t,n){e.resolve=t,e.reject=n});return e.promise=t,e}var r=e.async,i=t.EventTarget,s={};s.async=r;var o=function(){},u=function(e){var t=this,n=function(e){f(t,e),n=o,r=o},r=function(e){l(t,e),n=o,r=o};this.on("promise:resolved",function(e){this.trigger("success",{detail:e.detail})},this),this.on("promise:failed",function(e){this.trigger("error",{detail:e.detail})},this),e&&e(n,r)},a=function(e,t,n,r){var i=typeof n=="function",s,o,u,a;if(i)try{s=n(r.detail),u=!0}catch(c){a=!0,o=c}else s=r.detail,u=!0;s&&typeof s.then=="function"?s.then(function(e){f(t,e)},function(e){l(t,e)}):i&&u?f(t,s):a?l(t,o):e==="resolve"?f(t,s):e==="reject"&&l(t,s)};u.prototype={then:function(e,t){var n=new u;return this.isFulfilled&&s.async(function(){a("resolve",n,e,{detail:this.fulfillmentValue})},this),this.isRejected&&s.async(function(){a("reject",n,t,{detail:this.rejectedReason})},this),this.on("promise:resolved",function(t){a("resolve",n,e,t)}),this.on("promise:failed",function(e){a("reject",n,t,e)}),n}},i.mixin(u.prototype),n.Promise=u,n.all=c,n.defer=p,n.configure=h}),window.RSVP=t("rsvp")})(); (function(){var e,t;(function(){var n={},i={};e=function(e,t,i){n[e]={deps:t,callback:i}};t=function(e){if(i[e]){return i[e]}i[e]={};var r=n[e],o=r.deps,s=r.callback,f=[],c;for(var a=0,u=o.length;a<u;a++){if(o[a]==="exports"){f.push(c={})}else{f.push(t(o[a]))}}var l=s.apply(this,f);return i[e]=c||l}})();e("rsvp/async",["exports"],function(e){"use strict";var t=typeof window!=="undefined"?window:{};var n=t.MutationObserver||t.WebKitMutationObserver;var i;if(typeof process!=="undefined"&&{}.toString.call(process)==="[object process]"){i=function(e,t){process.nextTick(function(){e.call(t)})}}else if(n){var r=[];var o=new n(function(){var e=r.slice();r=[];e.forEach(function(e){var t=e[0],n=e[1];t.call(n)})});var s=document.createElement("div");o.observe(s,{attributes:true});window.addEventListener("unload",function(){o.disconnect();o=null});i=function(e,t){r.push([e,t]);s.setAttribute("drainQueue","drainQueue")}}else{i=function(e,t){setTimeout(function(){e.call(t)},1)}}e.async=i});e("rsvp/events",["exports"],function(e){"use strict";var t=function(e,t){this.type=e;for(var n in t){if(!t.hasOwnProperty(n)){continue}this[n]=t[n]}};var n=function(e,t){for(var n=0,i=e.length;n<i;n++){if(e[n][0]===t){return n}}return-1};var i=function(e){var t=e._promiseCallbacks;if(!t){t=e._promiseCallbacks={}}return t};var r={mixin:function(e){e.on=this.on;e.off=this.off;e.trigger=this.trigger;return e},on:function(e,t,r){var o=i(this),s,f;e=e.split(/\s+/);r=r||this;while(f=e.shift()){s=o[f];if(!s){s=o[f]=[]}if(n(s,t)===-1){s.push([t,r])}}},off:function(e,t){var r=i(this),o,s,f;e=e.split(/\s+/);while(s=e.shift()){if(!t){r[s]=[];continue}o=r[s];f=n(o,t);if(f!==-1){o.splice(f,1)}}},trigger:function(e,n){var r=i(this),o,s,f,c,a;if(o=r[e]){for(var u=0;u<o.length;u++){s=o[u];f=s[0];c=s[1];if(typeof n!=="object"){n={detail:n}}a=new t(e,n);f.call(c,a)}}}};e.EventTarget=r});e("rsvp",["rsvp/async","rsvp/events","exports"],function(e,t,n){"use strict";var i=e.async;var r=t.EventTarget;var o={};o.async=i;var s=function(){};var f=function(e){var t=this;var n=function(e){a(t,e);n=s;i=s};var i=function(e){u(t,e);n=s;i=s};this.on("promise:resolved",function(e){this.trigger("success",{detail:e.detail})},this);this.on("promise:failed",function(e){this.trigger("error",{detail:e.detail})},this);if(e){e(n,i)}};var c=function(e,t,n,i){var r=typeof n==="function",o,s,f,c;if(r){try{o=n(i.detail);f=true}catch(l){c=true;s=l}}else{o=i.detail;f=true}if(o&&typeof o.then==="function"){o.then(function(e){a(t,e)},function(e){u(t,e)})}else if(r&&f){a(t,o)}else if(c){u(t,s)}else if(e==="resolve"){a(t,o)}else if(e==="reject"){u(t,o)}};f.prototype={then:function(e,t){var n=new f;if(this.isFulfilled){o.async(function(){c("resolve",n,e,{detail:this.fulfillmentValue})},this)}if(this.isRejected){o.async(function(){c("reject",n,t,{detail:this.rejectedReason})},this)}this.on("promise:resolved",function(t){c("resolve",n,e,t)});this.on("promise:failed",function(e){c("reject",n,t,e)});return n}};function a(e,t){o.async(function(){e.trigger("promise:resolved",{detail:t});e.isFulfilled=true;e.fulfillmentValue=t})}function u(e,t){o.async(function(){e.trigger("promise:failed",{detail:t});e.isRejected=true;e.rejectedReason=t})}function l(e){var t,n=[];var i=new f;var r=e.length;if(r===0){a(i,[])}var o=function(e){return function(t){s(e,t)}};var s=function(e,t){n[e]=t;if(--r===0){a(i,n)}};var c=function(e){u(i,e)};for(t=0;t<r;t++){e[t].then(o(t),c)}return i}r.mixin(f.prototype);function v(e,t){o[e]=t}function p(){var e={};var t=new f(function(t,n){e.resolve=t;e.reject=n});e.promise=t;return e}n.Promise=f;n.all=l;n.defer=p;n.configure=v});window.RSVP=t("rsvp")})();
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
"devDependencies": { "devDependencies": {
"jshint": "~0.9", "jshint": "~0.9",
"promise-tests": "2.0.0", "promise-tests": "2.0.0",
"uglify-js": "~2.2" "uglify-js": "~2.2",
"es6-module-transpiler": "~0.1.2"
}, },
"scripts": { "scripts": {
"test": "promise-tests all ./tests/test-adapter", "test": "promise-tests all ./tests/test-adapter",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment