mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
FIX: assets:precompile:js_processor
task issue (#23219)
* Fix the reference * Use mutex in non-prod only (…and don't try to build the processor in runtime in prod)
This commit is contained in:
parent
4dfe25d062
commit
4fdeb6281e
|
@ -110,22 +110,17 @@ class DiscourseJsProcessor
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.generate_js_processor
|
def self.generate_js_processor
|
||||||
@processor_mutex.synchronize do
|
Discourse::Utils.execute_command(
|
||||||
if Rails.env.development? || Rails.env.test? ||
|
"yarn",
|
||||||
!File.exist?("#{Rails.root}/#{JS_PROCESSOR_PATH}")
|
"--silent",
|
||||||
Discourse::Utils.execute_command(
|
"esbuild",
|
||||||
"yarn",
|
"--log-level=warning",
|
||||||
"--silent",
|
"--bundle",
|
||||||
"esbuild",
|
"--external:fs",
|
||||||
"--log-level=warning",
|
"--define:process='{\"env\":{}}'",
|
||||||
"--bundle",
|
"app/assets/javascripts/js-processor.js",
|
||||||
"--external:fs",
|
"--outfile=#{JS_PROCESSOR_PATH}",
|
||||||
"--define:process='{\"env\":{}}'",
|
)
|
||||||
"app/assets/javascripts/js-processor.js",
|
|
||||||
"--outfile=#{JS_PROCESSOR_PATH}",
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.create_new_context
|
def self.create_new_context
|
||||||
|
@ -138,7 +133,10 @@ class DiscourseJsProcessor
|
||||||
ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) })
|
ctx.attach("rails.logger.error", proc { |err| Rails.logger.error(err.to_s) })
|
||||||
|
|
||||||
# Theme template AST transformation plugins
|
# Theme template AST transformation plugins
|
||||||
generate_js_processor
|
if Rails.env.development? || Rails.env.test?
|
||||||
|
@processor_mutex.synchronize { generate_js_processor }
|
||||||
|
end
|
||||||
|
|
||||||
ctx.eval(File.read(JS_PROCESSOR_PATH), filename: "js-processor.js")
|
ctx.eval(File.read(JS_PROCESSOR_PATH), filename: "js-processor.js")
|
||||||
|
|
||||||
ctx
|
ctx
|
||||||
|
|
|
@ -301,7 +301,7 @@ task "assets:precompile:compress_js" do
|
||||||
end
|
end
|
||||||
|
|
||||||
task "assets:precompile:js_processor": "environment" do
|
task "assets:precompile:js_processor": "environment" do
|
||||||
DiscourseJsProcessor.generate_js_processor
|
DiscourseJsProcessor::Transpiler.generate_js_processor
|
||||||
end
|
end
|
||||||
|
|
||||||
task "assets:precompile": %w[
|
task "assets:precompile": %w[
|
||||||
|
|
Loading…
Reference in New Issue
Block a user