On Click calling _ember_jquery at wrong path

I believe this is a problem with the way the source map is being generated, caused by this PR: https://github.com/discourse/discourse/pull/7834.

Previously, the -p relative option was used so source map paths looked like [‘admin…js.map’]. Starting with 2.4.beta9, the -p option is not available because of the change to uglify 3, so source map paths were absolute like [’/var/www/discourse/public/assets/admin…js.map’]. This caused the source maps to 404 when debugging since the actual file was at /assets, but the map indicated it was at /var/www/…/assets.

A workaround I found was to change lib/tasks/asset.rake to add the base option to the source map parameter so it looks like this:

  base = assets_path + ((d = File.dirname(from)) == "." ? "" : "/#{d}")

  cmd = <<~EOS
    uglifyjs '#{assets_path}/#{from}' -m -c -o '#{to_path}' --source-map "base='#{base}',root='#{source_map_root}',url='#{source_map_url}'" --output '#{to_path}'
  EOS

I can’t guarantee it would work for everyone, but it allows me to debug via source maps without the 404 errors.

3 Likes