From 9a07945a16c7657aded1e307b7e3ee6a8645a918 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 3 Feb 2015 13:14:05 -0500 Subject: [PATCH] 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. --- .../tilt/es6_module_transpiler_template.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb index 4081325d50b..27a860c34e5 100644 --- a/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb +++ b/lib/es6_module_transpiler/tilt/es6_module_transpiler_template.rb @@ -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