sprockets-es6 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -1
- data/lib/sprockets/es6/6to5.js +8 -6
- data/lib/sprockets/es6.rb +1 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bf0c0e0db08ba61dc723093a37cedf1563c2fa5
|
4
|
+
data.tar.gz: 5bfacde8d667d0e4746aa1600b858063cb789977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c202b33c3466523de2fd958bd7f961fd42adf8d4be326e7ef4c47ee0bd8700c8c35e690d5c1b4e8f51106ea1063d2797174c788352ce389810fe02a81e64a4c
|
7
|
+
data.tar.gz: 0388841eabe6ef52c92c8b79e0bd0ec529e299ccd3dc557380ccbf3fbaeb4bad5bc1f4376499abb308dc99a415cce2b8d632eed1371aae4d468082cc7af8567c
|
data/README.md
CHANGED
@@ -4,12 +4,19 @@ A Sprockets transformer that converts ES6 code into vanilla ES5 with [6to5](http
|
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
7
|
+
``` ruby
|
8
|
+
# Gemfile
|
9
|
+
gem 'sprockets'
|
10
|
+
gem 'sprockets-es6'
|
11
|
+
```
|
12
|
+
|
13
|
+
|
7
14
|
``` ruby
|
8
15
|
require 'sprockets/es6'
|
9
16
|
```
|
10
17
|
|
11
18
|
``` js
|
12
|
-
|
19
|
+
// app.es6
|
13
20
|
|
14
21
|
square = (x) => x * x
|
15
22
|
|
@@ -19,3 +26,7 @@ class Animal {
|
|
19
26
|
}
|
20
27
|
}
|
21
28
|
```
|
29
|
+
|
30
|
+
## Caveats
|
31
|
+
|
32
|
+
Requires Sprockets 3 betas.
|
data/lib/sprockets/es6/6to5.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.to5=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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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){
|
2
|
+
(function (global){
|
2
3
|
var transform = module.exports = require("./transformation/transform");
|
3
4
|
|
4
5
|
transform.transform = transform;
|
@@ -13,7 +14,7 @@ transform.load = function (url, callback, opts, hold) {
|
|
13
14
|
opts = opts || {};
|
14
15
|
opts.filename = opts.filename || url;
|
15
16
|
|
16
|
-
var xhr =
|
17
|
+
var xhr = global.ActiveXObject ? new global.ActiveXObject("Microsoft.XMLHTTP") : new global.XMLHttpRequest();
|
17
18
|
xhr.open("GET", url, true);
|
18
19
|
if ("overrideMimeType" in xhr) xhr.overrideMimeType("text/plain");
|
19
20
|
|
@@ -61,7 +62,7 @@ var runScripts = function () {
|
|
61
62
|
}
|
62
63
|
};
|
63
64
|
|
64
|
-
var _scripts =
|
65
|
+
var _scripts = global.document.getElementsByTagName("script");
|
65
66
|
for (var i in _scripts) {
|
66
67
|
var _script = _scripts[i];
|
67
68
|
if (types.indexOf(_script.type) >= 0) scripts.push(_script);
|
@@ -74,12 +75,13 @@ var runScripts = function () {
|
|
74
75
|
exec();
|
75
76
|
};
|
76
77
|
|
77
|
-
if (
|
78
|
-
|
79
|
-
} else {
|
80
|
-
|
78
|
+
if (global.addEventListener) {
|
79
|
+
global.addEventListener("DOMContentLoaded", runScripts, false);
|
80
|
+
} else if (global.attachEvent) {
|
81
|
+
global.attachEvent("onload", runScripts);
|
81
82
|
}
|
82
83
|
|
84
|
+
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
83
85
|
},{"./transformation/transform":26}],2:[function(require,module,exports){
|
84
86
|
module.exports = File;
|
85
87
|
|
data/lib/sprockets/es6.rb
CHANGED
@@ -3,15 +3,11 @@ require 'sprockets'
|
|
3
3
|
|
4
4
|
module Sprockets
|
5
5
|
class ES6
|
6
|
-
VERSION = '0.1.
|
6
|
+
VERSION = '0.1.1'
|
7
7
|
|
8
8
|
def self.context
|
9
9
|
@context ||= begin
|
10
10
|
js = <<-JS
|
11
|
-
// TODO: Patch 6to5
|
12
|
-
window = global;
|
13
|
-
window.attachEvent = function() {};
|
14
|
-
|
15
11
|
#{File.read(File.expand_path("../es6/6to5.js", __FILE__))}
|
16
12
|
|
17
13
|
function _transform() {
|