mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 18:43:38 +08:00
a01b1dd648
This makes a small improvement to 'cold cache' ember-cli build times, and a large improvement to 'warm cache' build times The ember-auto-import update means that vendor is now split into multiple files for efficiency. These are named `chunk.*`, and should be included immediately after the `vendor.js` file. This commit also updates the rails app to render script tags for these chunks. This change was previously merged, and caused memory-related errors on RAM-constrained machines. This was because Webpack 5 switches from multiple worker processes to a single multi-threaded process. This meant that it was hitting node's default heap size limit (~500mb on a 1GB RAM server). Discourse's standard install procedure recommends adding 2GB swap to 1GB-RAM machines, so we can afford to override's Node's default via the `--max-old-space-size` flag.
48 lines
1.3 KiB
Ruby
48 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module QunitHelper
|
|
|
|
def vendor_theme_tests
|
|
return preload_script("vendor-theme-tests") if @legacy_ember
|
|
preload_vendor_scripts
|
|
end
|
|
|
|
def support_bundles
|
|
result = []
|
|
if Rails.env.production? || @legacy_ember
|
|
result << preload_script("discourse/tests/test-support-rails")
|
|
result << preload_script("discourse/tests/test-helpers-rails")
|
|
else
|
|
result << preload_script("test-support")
|
|
result << preload_script("test-helpers")
|
|
end
|
|
result.join("\n").html_safe
|
|
end
|
|
|
|
def boot_bundles
|
|
result = []
|
|
if @legacy_ember
|
|
result << preload_script("discourse/tests/test_starter")
|
|
elsif @is_proxied
|
|
result << preload_script("scripts/discourse-test-listen-boot")
|
|
result << preload_script("scripts/discourse-boot")
|
|
else
|
|
result << preload_script("discourse-test-listen-boot")
|
|
result << preload_script("discourse-boot")
|
|
end
|
|
result.join("\n").html_safe
|
|
end
|
|
|
|
def theme_tests
|
|
theme = Theme.find_by(id: request.env[:resolved_theme_id])
|
|
return "" if theme.blank?
|
|
|
|
_, digest = theme.baked_js_tests_with_digest
|
|
src = "#{GlobalSetting.cdn_url}" \
|
|
"#{Discourse.base_path}" \
|
|
"/theme-javascripts/tests/#{theme.id}-#{digest}.js" \
|
|
"?__ws=#{Discourse.current_hostname}"
|
|
"<script src='#{src}'></script>".html_safe
|
|
end
|
|
end
|