ruby-hyperloop / hyperloop-config

The project has moved to Hyperstack!! - internal gem used by other hyperloop gems to define config settings
https://hyperstack.org/
MIT License
3 stars 4 forks source link

Webpack required Components file not found first boot #5

Open sfcgeorge opened 6 years ago

sfcgeorge commented 6 years ago

Following Hyperloop Webpack Tutorial doesn't quite work first boot.

Declare your React library in app/javascript/packs/client_and_server.js:

ReactMaterialize = require("react-materialize");

Run the command webpack, so it will generate the package client_and_server.js into public/packs

Tell Hyperloop where is located your package:

# config/initializers/hyperloop.rb:
config.import 'client_and_server'

In order to help Rails and Hyperloop to find the client_and_server.js package:

# config/initializers/assets.rb
Rails.application.config.assets.paths << Rails.root.join('public', 'packs')

But there is some kind of bug. I did the above, cleared cache and started the server but it refused to boot: couldn't find file 'client_and_server' with type 'application/javascript' (Sprockets::FileNotFound). However I can see the ./public/packs folder in the lookup paths in the error output below, so the config is correct.

I got it to work by commenting out `config.import 'client_and_server' and booting the server once. Of course Hyperloop can't find the component but at least the app boots this time.

Then I stop the server, add the config.import line back and restart the server. This time it can find the file and boots and the component works in Hyperloop.

So, what is Rails doing on that first boot that bin/webpack didn't do? Our webpacker config is stock but I note yours is different, perhaps Rails changed something.

I just reproduced the issue in our app by rm -rf tmp/cache again. You don't even have to load the app in a browser, just booting the app is enough.

Error Output
=> Booting Puma
=> Rails 5.1.4 application starting in development 
=> Run `rails server -h` for more startup options

##########################################################################
      HYPERLOOP LIBRARIES PRECOMPILING AND MINIFYING
  FIRST TIME BOOTING YOUR APP IT CAN TAKE 1 OR 2 MINUTES
 NB: You can force precompiling again by cleaning cache: rm -rf tmp/cache 
##########################################################################

Compiling the system assets for hyperloop-prerender-loader-system-code
    require 'opal' 
    require 'hyperloop-config' 
    require 'hyper-component' 
    require 'hyper-model' 
    require 'hyper-store' 
    require 'react/react-source-browser' 
    require 'react/react-source-server' # SERVER ONLY
    require 'hyper-react' 
    require 'hyper-operation' 
    require 'reactrb/auto-import' 
    require 'hyper-router' 
    require 'hyper-router/react-router-source' 
    require 'hyper-i18n' 
    require 'hyper-console' 
    require 'opal_hot_reloader' 
    require 'models/000_application_record' 
    require 'client_and_server' 
Exiting
/Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/resolve.rb:65:in `resolve!': couldn't find file 'client_and_server' with type 'application/javascript' (Sprockets::FileNotFound)
Checked in these paths: 
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/opal
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/stdlib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyperloop-config-0.9.11/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-jquery-0.4.2/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-store-0.2.3/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-activesupport-0.3.0/opal
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-react-0.12.7/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/react-rails-1.9.0/lib/assets/react-source/development-with-addons
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-react-0.12.7/lib/react-sources
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-component-0.12.3/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mutations-0.8.1/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-operation-0.5.12/lib/sources
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-operation-0.5.12/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-operation-0.5.12/vendor
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-mesh-0.6.0/lib/sources
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-mesh-0.6.0/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-mesh-0.6.0/vendor
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-model-0.6.0/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-browser-0.2.0/opal
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/paggio-0.2.6/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-router-4.1.1/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/hyper-i18n-6a3e0ce43f0f/lib
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal_hot_reloader-0.1.4/opal
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-console-0.1.4/lib
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/assets/flash
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/assets/fonts
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/assets/images
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/assets/javascripts
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/assets/stylesheets
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/vendor/assets/javascripts
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/vendor/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyper-console-0.1.4/vendor/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-rails-0.9.3/lib/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/sibyl-1b2d5a5ebeec/app/assets/images
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/sibyl-1b2d5a5ebeec/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/bundler/gems/sibyl-1b2d5a5ebeec/app/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails_admin-1.2.0/app/assets/images
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails_admin-1.2.0/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails_admin-1.2.0/app/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails_admin-1.2.0/vendor/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rails_admin-1.2.0/vendor/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/nested_form-0.3.2/vendor/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jquery-ui-rails-5.0.5/app/assets/images
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jquery-ui-rails-5.0.5/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jquery-ui-rails-5.0.5/app/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/font-awesome-rails-4.7.0.2/app/assets/fonts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/font-awesome-rails-4.7.0.2/app/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/remotipart-1.3.1/vendor/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/cocoon-1.2.10/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zeroclipboard-rails-0.1.2/app/assets/images
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/zeroclipboard-rails-0.1.2/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jquery-rails-4.3.1/vendor/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/fonts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/coffee-rails-4.2.2/lib/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actioncable-5.1.4/lib/assets/compiled
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/actionview-5.1.4/lib/assets/compiled
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/hyperloop
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/hyperloop
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/app/views
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/node_modules
  /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/public/packs
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/react-rails-1.9.0/lib/assets/react-source/development
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/react-rails-1.9.0/lib/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/stylesheets
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/javascripts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/fonts
  /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/materialize-sass-0.97.7/app/assets/images
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/context.rb:88:in `resolve'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy.rb:259:in `resolve_with_compat'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/context.rb:142:in `require_asset'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/lib/opal/sprockets/processor.rb:69:in `block in process_requires'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/lib/opal/sprockets/processor.rb:67:in `each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/lib/opal/sprockets/processor.rb:67:in `process_requires'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/opal-0.10.5/lib/opal/sprockets/processor.rb:48:in `evaluate'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/tilt-2.0.8/lib/tilt/template.rb:109:in `render'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/legacy_tilt_processor.rb:25:in `call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:23:in `block in call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/utils.rb:200:in `dfs'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:24:in `call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/environment.rb:30:in `find_asset'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:92:in `[]'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyperloop-config-0.9.11/lib/hyperloop/imports.rb:105:in `compile_and_compress'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyperloop-config-0.9.11/lib/hyperloop-prerender-loader-system.js.erb:1:in `_evaluate_template'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/erb_processor.rb:26:in `call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/erb_processor.rb:13:in `call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:23:in `block in call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/utils.rb:200:in `dfs'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/bundle.rb:24:in `call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:75:in `call_processor'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `reverse_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/processor_utils.rb:56:in `call_processors'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:134:in `load_from_unloaded'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:60:in `block in load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:317:in `fetch_asset_from_dependency_cache'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/loader.rb:44:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:20:in `block in initialize'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/cached_environment.rb:47:in `load'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/base.rb:66:in `find_asset'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/sprockets-3.7.1/lib/sprockets/environment.rb:30:in `find_asset'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/hyperloop-config-0.9.11/lib/hyperloop/rail_tie.rb:56:in `block in '
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:67:in `block in execute_hook'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:60:in `with_execution_control'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:65:in `execute_hook'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:50:in `block in run_load_hooks'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/lazy_load_hooks.rb:49:in `run_load_hooks'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/application/finisher.rb:73:in `block in '
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
    from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
    from /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/config/environment.rb:5:in `
' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require' from config.ru:2:in `block in
' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize' from config.ru:in `new' from config.ru:in `
' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:24:in `app' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:80:in `log_to_stdout' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:42:in `start' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:135:in `block in perform' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `tap' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands/server/server_command.rb:130:in `perform' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `
' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-1.1.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `block in require' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:292:in `require' from /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/bin/rails:9:in `' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/bin/spring:49:in `' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load' from /Users/sfcgeorge/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `' from /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/bin/spring:15:in `require' from /Users/sfcgeorge/Documents/Websites/Work/JobLab/code/joblab/bin/spring:15:in `' from bin/rails:3:in `load' from bin/rails:3:in `
'

Other issues with the docs:

sfcgeorge commented 6 years ago

The default configuration of Webpacker is to generate digests on all the packed files and store the mapping in manifest.json. Example contents:

{
  "client_and_server.js": "/packs/client_and_server-bbc5157a54ad4b47beb9.js"
}

I don't know the internals of the include mechanism / Sprockets but it seems it's not looking via the manifest so can't find the file as it has a digest.

Rails asset_pack_path correctly uses the manifest to do the lookup. Internally that calls Webpacker.manifest.lookup. Inside gems like react-rails they also use that lookup helper. So a fix for this issue is using lookup in hyperloop.rb:

# config/initializers/hyperloop.rb
Hyperloop.configuration do |config|
  # ...
  config.import(
    Webpacker.manifest.lookup("client_and_server.js")&.split("/")&.last
  )
end

Which works provided the packs folder is added to the asset pipeline as above:

# config/initializers/assets.rb
Rails.application.config.assets.paths << Rails.root.join('public', 'packs')

It's a little messy but does work. Another work around is to prevent generation of the digest by changing the webpack defaults. But I assume this is a bad idea as it will probably cause caching issues, but I'm not sure:

// config/webpack/custom.js
module.exports = {
  externals: {
    "react": "React",
    "react-dom": "ReactDOM"
  },
  output: {
    filename: 'client_and_server.js' // this prevents digest
  }
};

So hyperloop-config could be changed to automatically look via the manifest.json. But this may not be possible as you can't know what is an asset or what is a webpack thing, maybe an additional explicit option config.import "server_and_client", webpack: true

And/or the Webpack example could be updated to mention the above workaround[s].

sfcgeorge commented 6 years ago

I also believe that adding javascript_pack_tag as well as the require in hyperloop.rb does cause the libraries to be duplicated as I got errors in the browser to that effect. So don't add the pack tag, just the require and it seems to work.

catmando commented 6 years ago

So I am not sure what the conclusion of this will be but it should be either fixed, or at least documented/clarified with 0.15 release

janbiedermann commented 6 years ago

Rails.application.config.assets.paths << Rails.root.join('public', 'packs') This should NOT be done, sprockets should not have webpacker output paths in its load_path. I recommend to use the javascript_pack_tag for the client and for prerendering the new config.prerendering_files = ["your_webpack_bundle.js", "your_sprockets_files.js", "hyperloop-prerender-loader.js"] option, which knows how to access webpacker files. @sfcgeorge please confirm it working for you It should then be documented

sfcgeorge commented 6 years ago

Yep, now working without that adding packs to assets hack line.