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:
parent
4be0e86f1e
commit
ebb5c1ff4d
|
@ -1,5 +1,6 @@
|
|||
import getURL from "discourse-common/lib/get-url";
|
||||
import PreloadStore from "discourse/lib/preload-store";
|
||||
import { isDevelopment } from "discourse-common/config/environment";
|
||||
|
||||
export default function identifySource(error) {
|
||||
if (!error || !error.stack) {
|
||||
|
@ -26,6 +27,28 @@ export default function identifySource(error) {
|
|||
};
|
||||
}
|
||||
}
|
||||
|
||||
let plugin;
|
||||
|
||||
if (isDevelopment()) {
|
||||
// Source-mapped:
|
||||
plugin = plugin || error.stack.match(/plugins\/([\w-]+)\//)?.[1];
|
||||
|
||||
// Un-source-mapped:
|
||||
plugin = plugin || error.stack.match(/assets\/plugins\/([\w-]+)\.js/)?.[1];
|
||||
}
|
||||
|
||||
// Production mode
|
||||
plugin =
|
||||
plugin ||
|
||||
error.stack.match(/assets\/plugins\/_?([\w-]+)-[0-9a-f]+\.js/)?.[1];
|
||||
|
||||
if (plugin) {
|
||||
return {
|
||||
type: "plugin",
|
||||
name: plugin,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function getThemeInfo(id) {
|
||||
|
@ -41,6 +64,9 @@ export function consolePrefix(error, source) {
|
|||
source = source || identifySource(error);
|
||||
if (source && source.type === "theme") {
|
||||
return `[THEME ${source.id} '${source.name}']`;
|
||||
} else if (source && source.type === "plugin") {
|
||||
return `[PLUGIN ${source.name}]`;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -241,7 +241,7 @@ module Discourse
|
|||
config.assets.enabled = true
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets
|
||||
config.assets.version = '1.2.4'
|
||||
config.assets.version = '1.2.5'
|
||||
|
||||
# see: http://stackoverflow.com/questions/11894180/how-does-one-correctly-add-custom-sql-dml-in-migrations/11894420#11894420
|
||||
config.active_record.schema_format = :sql
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue