mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
PERF: Speed up JSHint tests by using local buffers instead of AJAX
requests.
This commit is contained in:
@@ -23,7 +23,17 @@ class DiscourseIIFE < Sprockets::Processor
|
||||
return data if path =~ /\.shbrs/
|
||||
return data if path =~ /\.hbrs/
|
||||
|
||||
"(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);"
|
||||
res = "(function () {\n\nvar $ = window.jQuery;\n// IIFE Wrapped Content Begins:\n\n#{data}\n\n// IIFE Wrapped Content Ends\n\n })(this);"
|
||||
|
||||
# Include JS code for JSHint
|
||||
unless Rails.env.production?
|
||||
req_path = path.sub(Rails.root.to_s, '')
|
||||
.sub("/app/assets/javascripts", "")
|
||||
.sub("/test/javascripts", "")
|
||||
res << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['/assets#{req_path}'] = #{data.to_json};\n"
|
||||
end
|
||||
|
||||
res
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -65,6 +65,8 @@ module Tilt
|
||||
@output = klass.v8.eval(generate_source(scope))
|
||||
end
|
||||
|
||||
source = @output.dup
|
||||
|
||||
# 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.
|
||||
@@ -81,6 +83,12 @@ module Tilt
|
||||
@output << "\n\nDiscourse.#{class_name}#{type.classify} = require('#{require_name}').default"
|
||||
end
|
||||
|
||||
# Include JS code for JSHint
|
||||
unless Rails.env.production?
|
||||
req_path = "/assets/#{scope.logical_path}.js"
|
||||
@output << "\nwindow.__jshintSrc = window.__jshintSrc || {}; window.__jshintSrc['#{req_path}'] = #{source.to_json};\n"
|
||||
end
|
||||
|
||||
@output
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user