A platform for community discussion. Free, open, simple.
DEV: Patch Sprockets::DirectiveProcessor to avoid extra newline (#21203)
David Taylor56115977c027
diff --git a/lib/freedom_patches/sprockets_patches.rb b/lib/freedom_patches/sprockets_patches.rbindex b9fb4974143..a32286dddfe 100644--- a/lib/freedom_patches/sprockets_patches.rb+++ b/lib/freedom_patches/sprockets_patches.rb@@ -36,3 +36,16 @@ if Rails.env.development? || Rails.env.test?alias_method :public_compute_asset_path, :compute_asset_pathendend++# By default, the Sprockets DirectiveProcessor introduces a newline between possible 'header' comments+# and the rest of the JS file. (https://github.com/rails/sprockets/blob/f4d3dae71e/lib/sprockets/directive_processor.rb#L121)+# This causes sourcemaps to be offset by 1 line, and therefore breaks browser tooling.+# We know that Ember-Cli assets do not use Sprockets directives, so we can totally bypass the DirectiveProcessor for those files.+Sprockets::DirectiveProcessor.prepend(+ Module.new do+ def process_source(source)+ return source, [] if EmberCli.is_ember_cli_asset?(File.basename(@filename))+ super+ end+ end,+)