FIX: Don't add constants for ES6 modules in plugins

If you're using ES6 in a plugin, you shouldn't be depending on the
backwards compatibility layer. That's for proper Discourse only.
This commit is contained in:
Robin Ward 2015-02-03 13:14:05 -05:00
parent d0630b7f26
commit 9a07945a16
1 changed files with 4 additions and 2 deletions

View File

@ -70,7 +70,9 @@ module Tilt
# For backwards compatibility with plugins, for now export the Global format too.
# We should eventually have an upgrade system for plugins to use ES6 or some other
# resolve based API.
if ENV['DISCOURSE_NO_CONSTANTS'].nil? && scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes|mixins|models)\/(.*)/
if ENV['DISCOURSE_NO_CONSTANTS'].nil? &&
scope.logical_path =~ /(discourse|admin)\/(controllers|components|views|routes|mixins|models)\/(.*)/
type = Regexp.last_match[2]
file_name = Regexp.last_match[3].gsub(/[\-\/]/, '_')
class_name = file_name.classify
@ -81,7 +83,7 @@ module Tilt
end
require_name = module_name(scope.root_path, scope.logical_path)
if require_name !~ /\-test$/
if require_name !~ /\-test$/ && require_name !~ /^discourse\/plugins\//
result = "#{class_name}#{type.classify}"
# HAX