js-routes: Allow precompilation of routes.js file in development. #5232
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
It looks like running MarkUs with Docker on WSL 2 runs into a webpacker compilation error:
I tried out various approaches in usabilityhub/rails-erb-loader#63 but didn't find one that worked (setting
DISABLE_SPRING
to1
, usingbundle exec
). When I inspect the webpack-dev-server output I see some permission errors associated with running rails, whichrails-erb-loader
does in a separate process.Your Changes
Description: I've introduced a workaround to precompile the js-routes file by doing
rails js:routes
, which generatesapp/javascript/routes.js
. If present, this file will be imported byapplication.js
instead ofroutes.js.erb
.Type of change (select all that apply):
Testing
I verified that this allows webpacker to compile all of the required assets, so MarkUs can actually run!
Questions and Comments (if applicable)
I changed the extension
.erb
to.js.erb
to allow webpacker to findroutes.js.erb
. We don't have any other assets that use the.erb
extension (e.g.,.css.erb
), but if we ever do want that, we'll need to add them separately to the extensions list inwebpacker.config
. But I think it's best to limit our use ofrails-erb-loader
until we can figure out the root cause of this WSL issue.Checklist
Required documentation changes (if applicable)
I'm updating https://github.com/MarkUsProject/Markus/wiki/Developer-Guide--Set-Up-With-Docker to include setup instructions for WSL 2, and will include the js routes precompilation step for this platform.