Skip to content

Instantly share code, notes, and snippets.

@ambar
Last active November 30, 2015 07:28
Show Gist options
  • Save ambar/f30ce12d889dbe6468de to your computer and use it in GitHub Desktop.
Save ambar/f30ce12d889dbe6468de to your computer and use it in GitHub Desktop.

Revisions

  1. ambar revised this gist Nov 30, 2015. No changes.
  2. ambar created this gist Nov 30, 2015.
    2 changes: 2 additions & 0 deletions babel.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    cp ./foo.es ./foo.js
    babel ./foo.js --preset es2015 --source-maps inline -o ./foo.js
    2 changes: 2 additions & 0 deletions foo.es
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    class Foo {}
    debugger
    11 changes: 11 additions & 0 deletions foo.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    "use strict";

    function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

    var Foo = function Foo() {
    _classCallCheck(this, Foo);
    };

    debugger;

    //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0lBQU0sR0FBRyxZQUFILEdBQUc7d0JBQUgsR0FBRzs7O0FBQ1QsU0FBUSIsImZpbGUiOiJmb28uanMiLCJzb3VyY2VzQ29udGVudCI6WyJjbGFzcyBGb28ge31cbmRlYnVnZ2VyXG4iXX0=
    32 changes: 32 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    </head>
    <body>
    <script>
    var fetchScript = function(scriptUrl) {
    fetch(scriptUrl)
    .then(function(r) {
    return r.text()
    })
    .then(function(r) {
    // eval(r)
    eval(r + '\n//# sourceURL=' + scriptUrl)
    })
    }

    var loadScript = function(scriptUrl) {
    var script = document.createElement('script')
    script.src = scriptUrl
    document.body.appendChild(script)
    }

    // var url = '/foo.js'
    var url = 'http://localhost:3000/foo.js'
    fetchScript(url)
    // loadScript(url)
    </script>
    </body>
    </html>