-
Notifications
You must be signed in to change notification settings - Fork 150
Description
Thank you for this new gem! I'm trying to get source maps working, I apologize in advance if I misunderstood (I have a limited understanding of front-end tooling).
Source maps do seem to work in our Rails 7 app in development (using sprockets 4.0.2, sprockets-rails 3.4.2, jsbundling-rails 1.0.1 and esbuild 0.14.23): assets:precompile generates a JS bundle with a sourceMappingURL clause at the end. However they do not seem to work in production: the sourceMappingURL clause is absent in this case.
Because of this we do not have proper Javascript crash reports in our monitoring system.
We have this under package.json's scripts: "build": "esbuild app/javascript/*.* --bundle --sourcemap --target=es2016 --minify --outdir=app/assets/builds". I've tried with both config.assets.debug = false (as suggested) and config.assets.debug = true in application.rb, but this does not seem to change the situation. Some debug info below (point 3 is problematic).
-
When running that
esbuildcommand, two files are generated as expected:app/assets/builds/application.jsandapp/assets/builds/application.js.map, where the last line of the JS file is//# sourceMappingURL=application.js.map. -
When running
RAILS_ENV=development bin/rails assets:precompile, two files are generated:public/assets/application-cc3245bb241eac905dc4ffd8a5abc8d3d42445e9e1986ea93ba7b267e583f1cf.jsandpublic/assets/application.js-67cdc37aff88978cfa5a2cdba39ef49c3da8d9b6ff16f4c7eca581548009fe0c.map, and the last lines of the JS file are (which seem correct):
//# sourceMappingURL=/assets/application.js-67cdc37aff88978cfa5a2cdba39ef49c3da8d9b6ff16f4c7eca581548009fe0c.map
//!
;
- When running
RAILS_ENV=production bin/rails assets:precompile, two files are generated:public/assets/application-6c7fc839b49f22a88c3f45c04cde931d8a6801ad0312f478165ac605915c1d55.jsandpublic/assets/application.js-67cdc37aff88978cfa5a2cdba39ef49c3da8d9b6ff16f4c7eca581548009fe0c.map. However the JS file has nosourceMappingURLstatement at the end, it ends with//!.
Is there a way to make source maps work with jsbundling-rails and esbuild?