mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
PERF: Update ember-auto-import and webpack (#15919)
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.
This commit is contained in:
@ -135,6 +135,22 @@ module ApplicationHelper
|
||||
path
|
||||
end
|
||||
|
||||
def preload_vendor_scripts
|
||||
scripts = ["vendor"]
|
||||
|
||||
if ENV["EMBER_CLI_PROD_ASSETS"] == "1"
|
||||
@@vendor_chunks ||= begin
|
||||
all_assets = ActionController::Base.helpers.assets_manifest.assets
|
||||
all_assets.keys.filter_map { |name| name[/\A(chunk\..*)\.js\z/, 1] }
|
||||
end
|
||||
scripts.push(*@@vendor_chunks)
|
||||
end
|
||||
|
||||
scripts.map do |name|
|
||||
preload_script(name)
|
||||
end.join("\n").html_safe
|
||||
end
|
||||
|
||||
def preload_script(script)
|
||||
path = script_asset_path(script)
|
||||
preload_script_url(path)
|
||||
|
Reference in New Issue
Block a user