DEV: Prefix deprecation notices with plugin name (#15942)

To make this possible in development mode, the `sourceURL=` implementation needs to include something plugin-specific. This has no effect on production.

The asset version is bumped in order to trigger a re-compilation of plugin JS assets.
This commit is contained in:
David Taylor
2022-02-14 20:13:52 +00:00
committed by GitHub
parent 4be0e86f1e
commit ebb5c1ff4d
3 changed files with 35 additions and 2 deletions

View File

@ -19,7 +19,14 @@ class DiscourseJsProcessor
# add sourceURL until we can do proper source maps
unless Rails.env.production?
data = "eval(#{data.inspect} + \"\\n//# sourceURL=#{logical_path}\");\n"
plugin_name = root_path[/\/plugins\/([\w-]+)\/assets/, 1]
source_url = if plugin_name
"plugins/#{plugin_name}/assets/javascripts/#{logical_path}"
else
logical_path
end
data = "eval(#{data.inspect} + \"\\n//# sourceURL=#{source_url}\");\n"
end
{ data: data }