Reproduction steps:
-
create a new hyperstack project
-
compile assets with bundle exec rake assets:precompile
-
start server in production environnment
-
Open your browser on localhost:3000
Expected result
Page should load without javascript errors
Actual result:
The page is blank with the following error:
Uncaught ReferenceError: require is not defined
Solution
I think this is due to the following line:
hyper-component-1.0.alpha1.8/lib/hyper-component.rb:7
Hyperstack.js_import 'react_ujs', defines: 'ReactRailsUJS'
sprockets-rails opens node_modules/react_ujs/package.json in order to determine the file to insert in application.js.
Unfortunally "main" is equal to react_ujs/index.js and this file contains "var React=require("react")"
I don't understand why "main" is not equal to react_ujs/dist/react_ujs.js.
My solution is to replace hyper-component-1.0.alpha1.8/lib/hyper-component.rb:7 by:
Hyperstack.js_import 'react_ujs/react_ujs/dist/react_ujs.js', defines: 'ReactRailsUJS'
Reproduction steps:
create a new hyperstack project
compile assets with
bundle exec rake assets:precompilestart server in production environnment
Open your browser on localhost:3000
Expected result
Page should load without javascript errors
Actual result:
The page is blank with the following error:
Uncaught ReferenceError: require is not definedSolution
I think this is due to the following line:
hyper-component-1.0.alpha1.8/lib/hyper-component.rb:7
Hyperstack.js_import 'react_ujs', defines: 'ReactRailsUJS'sprockets-rails opens node_modules/react_ujs/package.json in order to determine the file to insert in application.js.
Unfortunally "main" is equal to react_ujs/index.js and this file contains "var React=require("react")"
I don't understand why "main" is not equal to react_ujs/dist/react_ujs.js.
My solution is to replace hyper-component-1.0.alpha1.8/lib/hyper-component.rb:7 by:
Hyperstack.js_import 'react_ujs/react_ujs/dist/react_ujs.js', defines: 'ReactRailsUJS'