rmosolgo / react-rails-hot-loader

Live-reload React.js components with Ruby on Rails & react-rails
MIT License
88 stars 24 forks source link

[HotLoader] SyntaxError: Unexpected token < #7

Closed SqueezedLight closed 8 years ago

SqueezedLight commented 8 years ago

Hi guys, react hot loader is not working anymore and i miss it very much ;) When i save a file, this is what i typically see in my console:

[HotLoader] updating: _file.js.jsx
[HotLoader] SyntaxError: Unexpected token <
[HotLoader] update finished

I'm not totally sure, but i think recent updates broke it. Currently i'm using the following: ruby 2.3.0, react-rails-hot-loader-0.4.0, react-rails-1.5.0 and puma-2.15.3.

There is this troubleshooting area for react hot loader and fortunately the error Unexpected token < is listed there, but this didn't get me any further... Here is the link.

Any ideas on how to debug or solve his issue?

Every help is greatly appreciated, thanks a lot Tom

superplussed commented 8 years ago

+1

rmosolgo commented 8 years ago

Very weird, do you remember any of your recent updates?

Could you share your Gemfile.lock & the .js.jsx file which is broken?

(By the way, this project isn't at all related to Dan Abramov's hot loader! Although there might be some good code to borrow from there...)

SqueezedLight commented 8 years ago

Sure, here is my Gemfile.lock. The problem is not with just one file. There is absolutely no .js.jsx file that updates correctly.

GEM
  remote: https://rubygems.org/
  specs:
    CFPropertyList (2.3.2)
    actionmailer (4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.5)
      actionview (= 4.2.5)
      activesupport (= 4.2.5)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    activejob (4.2.5)
      activesupport (= 4.2.5)
      globalid (>= 0.3.0)
    activemodel (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
    activerecord (4.2.5)
      activemodel (= 4.2.5)
      activesupport (= 4.2.5)
      arel (~> 6.0)
    activerecord-session_store (0.1.2)
      actionpack (>= 4.0.0, < 5)
      activerecord (>= 4.0.0, < 5)
      railties (>= 4.0.0, < 5)
    activeresource (4.0.0)
      activemodel (~> 4.0)
      activesupport (~> 4.0)
      rails-observers (~> 0.1.1)
    activesupport (4.2.5)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    addressable (2.4.0)
    annotate (2.6.10)
      activerecord (>= 3.2, <= 4.3)
      rake (~> 10.4)
    arel (6.0.3)
    autoprefixer-rails (6.3.1)
      execjs
      json
    aws-sdk (1.61.0)
      aws-sdk-v1 (= 1.61.0)
    aws-sdk-v1 (1.61.0)
      json (~> 1.4)
      nokogiri (>= 1.4.4)
    babel-source (5.8.34)
    babel-transpiler (0.7.0)
      babel-source (>= 4.0, < 6)
      execjs (~> 2.0)
    bcrypt (3.1.10)
    binding_of_caller (0.7.2)
      debug_inspector (>= 0.0.1)
    browserify-rails (2.2.1)
      railties (>= 4.0.0, < 5.0)
      sprockets (> 3.0.2)
    builder (3.2.2)
    bullet (5.0.0)
      activesupport (>= 3.0.0)
      uniform_notifier (~> 1.9.0)
    byebug (8.2.1)
    capybara (2.2.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    concurrent-ruby (1.0.0)
    connection_pool (2.2.0)
    css_parser (1.3.7)
      addressable
    dalli (2.7.5)
    debug_inspector (0.0.2)
    delayed_job (4.1.1)
      activesupport (>= 3.0, < 5.0)
    delayed_job_active_record (4.1.0)
      activerecord (>= 3.0, < 5)
      delayed_job (>= 3.0, < 5)
    easy_translate (0.5.0)
      json
      thread
      thread_safe
    em-websocket (0.5.1)
      eventmachine (>= 0.12.9)
      http_parser.rb (~> 0.6.0)
    erubis (2.7.0)
    eventmachine (1.0.9.1)
    excon (0.45.4)
    execjs (2.6.0)
    factory_girl (4.4.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.4.1)
      factory_girl (~> 4.4.0)
      railties (>= 3.0.0)
    faker (1.3.0)
      i18n (~> 0.5)
    faraday (0.9.2)
      multipart-post (>= 1.2, < 3)
    figaro (1.1.1)
      thor (~> 0.14)
    fission (0.5.0)
      CFPropertyList (~> 2.2)
    fog (1.37.0)
      fog-aliyun (>= 0.1.0)
      fog-atmos
      fog-aws (>= 0.6.0)
      fog-brightbox (~> 0.4)
      fog-core (~> 1.32)
      fog-dynect (~> 0.0.2)
      fog-ecloud (~> 0.1)
      fog-google (<= 0.1.0)
      fog-json
      fog-local
      fog-powerdns (>= 0.1.1)
      fog-profitbricks
      fog-radosgw (>= 0.0.2)
      fog-riakcs
      fog-sakuracloud (>= 0.0.4)
      fog-serverlove
      fog-softlayer
      fog-storm_on_demand
      fog-terremark
      fog-vmfusion
      fog-voxel
      fog-vsphere (>= 0.4.0)
      fog-xenserver
      fog-xml (~> 0.1.1)
      ipaddress (~> 0.5)
    fog-aliyun (0.1.0)
      fog-core (~> 1.27)
      fog-json (~> 1.0)
      ipaddress (~> 0.8)
      xml-simple (~> 1.1)
    fog-atmos (0.1.0)
      fog-core
      fog-xml
    fog-aws (0.8.1)
      fog-core (~> 1.27)
      fog-json (~> 1.0)
      fog-xml (~> 0.1)
      ipaddress (~> 0.8)
    fog-brightbox (0.10.1)
      fog-core (~> 1.22)
      fog-json
      inflecto (~> 0.0.2)
    fog-core (1.35.0)
      builder
      excon (~> 0.45)
      formatador (~> 0.2)
    fog-dynect (0.0.2)
      fog-core
      fog-json
      fog-xml
    fog-ecloud (0.3.0)
      fog-core
      fog-xml
    fog-google (0.1.0)
      fog-core
      fog-json
      fog-xml
    fog-json (1.0.2)
      fog-core (~> 1.0)
      multi_json (~> 1.10)
    fog-local (0.2.1)
      fog-core (~> 1.27)
    fog-powerdns (0.1.1)
      fog-core (~> 1.27)
      fog-json (~> 1.0)
      fog-xml (~> 0.1)
    fog-profitbricks (0.0.5)
      fog-core
      fog-xml
      nokogiri
    fog-radosgw (0.0.5)
      fog-core (>= 1.21.0)
      fog-json
      fog-xml (>= 0.0.1)
    fog-riakcs (0.1.0)
      fog-core
      fog-json
      fog-xml
    fog-sakuracloud (1.7.5)
      fog-core
      fog-json
    fog-serverlove (0.1.2)
      fog-core
      fog-json
    fog-softlayer (1.0.3)
      fog-core
      fog-json
    fog-storm_on_demand (0.1.1)
      fog-core
      fog-json
    fog-terremark (0.1.0)
      fog-core
      fog-xml
    fog-vmfusion (0.1.0)
      fission
      fog-core
    fog-voxel (0.1.0)
      fog-core
      fog-xml
    fog-vsphere (0.5.0)
      fog-core
      rbvmomi (~> 1.8)
    fog-xenserver (0.2.3)
      fog-core
      fog-xml
    fog-xml (0.1.2)
      fog-core
      nokogiri (~> 1.5, >= 1.5.11)
    font_assets (0.1.12)
      rack
    formatador (0.2.5)
    geocoder (1.2.14)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    hashie (3.4.3)
    heroics (0.0.14)
      erubis (~> 2.7.0)
      excon
      moneta
      multi_json (>= 1.9.2)
      netrc
    heroku-deflater (0.6.2)
      rack (>= 1.4.5)
    highline (1.7.8)
    historyjs-rails (1.0.1)
      railties (>= 3.0)
    htmlentities (4.3.4)
    http_accept_language (2.0.5)
    http_parser.rb (0.6.0)
    i18n (0.7.0)
    i18n-js (3.0.0.rc12)
      i18n (~> 0.6, >= 0.6.6)
    i18n-tasks (0.8.7)
      activesupport (>= 2.3.18)
      easy_translate (>= 0.5.0)
      erubis
      highline (>= 1.7.3)
      i18n
      term-ansicolor (>= 1.3.2)
      terminal-table (>= 1.5.1)
    inflecto (0.0.2)
    ipaddress (0.8.2)
    jbuilder (1.5.3)
      activesupport (>= 3.0.0)
      multi_json (>= 1.2.0)
    jquery-rails (4.0.5)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.3)
    jwt (1.5.2)
    libv8 (3.16.14.13)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mailchimp-api (2.0.6)
      excon (>= 0.16.0)
      json (>= 1.7.7)
    memcachier (0.0.2)
    mime-types (1.25.1)
    mimemagic (0.3.0)
    mini_portile2 (2.0.0)
    minitest (5.8.3)
    moneta (0.8.0)
    multi_json (1.11.2)
    multi_xml (0.5.5)
    multipart-post (2.0.0)
    netrc (0.11.0)
    newrelic_rpm (3.14.1.311)
    nokogiri (1.6.7.1)
      mini_portile2 (~> 2.0.0.rc2)
    nprogress-rails (0.1.6.7)
    oauth2 (1.0.0)
      faraday (>= 0.8, < 0.10)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (~> 1.2)
    omniauth (1.3.1)
      hashie (>= 1.2, < 4)
      rack (>= 1.0, < 3)
    omniauth-facebook (3.0.0)
      omniauth-oauth2 (~> 1.2)
    omniauth-oauth2 (1.4.0)
      oauth2 (~> 1.0)
      omniauth (~> 1.2)
    paperclip (4.3.2)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      cocaine (~> 0.5.5)
      mime-types
      mimemagic (= 0.3.0)
    pg (0.18.4)
    pg_search (1.0.5)
      activerecord (>= 3.1)
      activesupport (>= 3.1)
      arel
    platform-api (0.5.0)
      heroics
    premailer (1.8.6)
      css_parser (>= 1.3.6)
      htmlentities (>= 4.0.0)
    premailer-rails (1.9.0)
      actionmailer (>= 3, < 5)
      premailer (~> 1.7, >= 1.7.9)
    public_activity (1.4.2)
      actionpack (>= 3.0.0)
      activerecord (>= 3.0)
      i18n (>= 0.5.0)
      railties (>= 3.0.0)
    puma (2.15.3)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rack-timeout (0.3.2)
    rails (4.2.5)
      actionmailer (= 4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      activemodel (= 4.2.5)
      activerecord (= 4.2.5)
      activesupport (= 4.2.5)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.5)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.2)
      loofah (~> 2.0)
    rails-observers (0.1.2)
      activemodel (~> 4.0)
    rails_12factor (0.0.3)
      rails_serve_static_assets
      rails_stdout_logging
    rails_serve_static_assets (0.0.4)
    rails_stdout_logging (0.0.4)
    railties (4.2.5)
      actionpack (= 4.2.5)
      activesupport (= 4.2.5)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.5.0)
    rbvmomi (1.8.2)
      builder
      nokogiri (>= 1.4.1)
      trollop
    react-rails (1.5.0)
      babel-transpiler (>= 0.7.0)
      coffee-script-source (~> 1.8)
      connection_pool
      execjs
      rails (>= 3.2)
      tilt
    react-rails-hot-loader (0.4.0)
      em-websocket
      rails
      react-rails
    ref (2.0.0)
    responders (2.1.1)
      railties (>= 4.2.0, < 5.1)
    rest-client (1.6.9)
      mime-types (~> 1.16)
    sass (3.4.21)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    spork (0.9.2)
    spring (1.6.2)
    sprockets (3.5.2)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-rails (3.0.0)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    term-ansicolor (1.3.2)
      tins (~> 1.0)
    terminal-table (1.5.2)
    therubyracer (0.12.2)
      libv8 (~> 3.16.14.0)
      ref
    thor (0.19.1)
    thread (0.2.2)
    thread_safe (0.3.5)
    tilt (2.0.2)
    tins (1.8.2)
    trollop (2.1.2)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (2.7.2)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    uniform_notifier (1.9.0)
    web-console (2.0.0)
      activemodel (~> 4.0)
      binding_of_caller (>= 0.7.2)
      railties (~> 4.0)
      sprockets-rails (>= 2.0, < 4.0)
    will_paginate (3.0.7)
    xml-simple (1.1.5)
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord-session_store (~> 0.1.1)
  activeresource (~> 4.0.0)
  annotate (~> 2.6.3)
  api-auth!
  apipie-rails!
  autoprefixer-rails
  aws-sdk (~> 1.61.0)
  bcrypt (~> 3.1.9)
  browserify-rails
  bullet
  byebug
  capybara (~> 2.2.1)
  dalli
  delayed_job_active_record
  factory_girl_rails (~> 4.4.1)
  faker (~> 1.3.0)
  figaro
  fog
  font_assets
  geocoder (~> 1.2.9)
  heroku-deflater
  historyjs-rails
  http_accept_language
  i18n-js (>= 3.0.0.rc8)
  i18n-tasks (~> 0.8.6)
  jbuilder (~> 1.2)
  jquery-rails (~> 4.0.4)
  mailchimp-api (~> 2.0.6)
  memcachier
  newrelic_rpm
  nokogiri
  nprogress-rails (~> 0.1.6.7)
  omniauth (~> 1.3, >= 1.3.1)
  omniauth-facebook (~> 3.0.0)
  paperclip
  pg (~> 0.18.1)
  pg_search
  platform-api
  premailer-rails
  public_activity
  puma
  rack-timeout
  rails
  rails_12factor (~> 0.0.3)
  railties
  react-rails
  react-rails-hot-loader
  responders (~> 2.1.0)
  rest-client (~> 1.6.7)
  sass-rails (~> 5.0.1)
  simple_hashtag!
  spork (~> 0.9.2)
  spring
  therubyracer (~> 0.12.1)
  turbolinks (~> 2.5.3)
  uglifier (~> 2.7.0)
  web-console (~> 2.0.0.beta2)
  will_paginate (~> 3.0.7)

BUNDLED WITH
   1.11.2
rmosolgo commented 8 years ago

Ohh thanks, I bet it's an issue with Sprockets 3 compatibility. Sprockets 3 changed the way to process an asset and it looks like this isn't working.

Let me take a look!

rmosolgo commented 8 years ago

replicated here: https://github.com/rmosolgo/react-rails-hot-loader/pull/8

superplussed commented 8 years ago

Wow, you are the MAN for taking a look at this so quickly. Was trying to wrap my head around how this was done and assumed that somehow sprockets was not handling .jsx well, but couldn't figure out a fix.

rmosolgo commented 8 years ago

Ohhkayy turns out in Sprockets 3, you get a different asset depending on the path you use (which makes sense). So:

Rails.application.assets["component.js.jsx"] # => Untransformed JSX 
Rails.application.assets["component.js"] # => Transformed JS 

Ya know, it makes sense, but it took forever to track it down!

I just pushed 0.5.0, could you give it a try and see if it works for you too?

SqueezedLight commented 8 years ago

YES!! It works again! I'm so glad i can use this again. Thank you very much! It was impossible for me to track this down and i really appreciate your effort.

rmosolgo commented 8 years ago

woo hoo!