Shopify / sprockets-commoner

Use Babel in Sprockets to compile JavaScript modules for the browser
MIT License
182 stars 22 forks source link

Not working in Node v7 #56

Closed darokel closed 7 years ago

darokel commented 7 years ago

I ran into the following issue (logged in the browser console) after following the setup instructions in the read me:

application-835093f….js:12179 Uncaught TypeError: Cannot read property 'App' of undefined
    at application-835093f….js:12179
    at Object.<anonymous> (application-835093f….js:12182)
    at __commoner_initialize_module__ (application-835093f….js:4)
    at application-835093f….js:12170
    at application-835093f….js:21648
(anonymous) @ application-835093f….js:12179
(anonymous) @ application-835093f….js:12182
__commoner_initialize_module__ @ application-835093f….js:4
(anonymous) @ application-835093f….js:12170
(anonymous) @ application-835093f….js:21648
//application.js

import {map} from 'lodash';

console.log(map([1, 2, 3], (n) => n * 3));

Versions:

Ruby 2.3.1 Rails v5.0.1 Node v7.1.0

PS I've set up the project with Yarn instead of NPM.

darokel commented 7 years ago

Nevermind, the default code for cable.js was causing the issue:

//cable.js
(function() {
  this.App || (this.App = {});

  App.cable = ActionCable.createConsumer();

}).call(this);