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:
parent
c4e34047a1
commit
a01b1dd648
|
@ -15,10 +15,11 @@
|
|||
"start": "ember serve"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"xss": "^1.0.8"
|
||||
"xss": "^1.0.8",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
|
@ -15,17 +15,18 @@
|
|||
"start": "ember serve"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"handlebars": "^4.7.0",
|
||||
"truth-helpers": "^1.0.0",
|
||||
"@uppy/aws-s3": "^2.0.4",
|
||||
"@uppy/aws-s3-multipart": "^2.1.0",
|
||||
"@uppy/core": "^2.1.0",
|
||||
"@uppy/drop-target": "^1.1.0",
|
||||
"@uppy/utils": "^4.0.3",
|
||||
"@uppy/xhr-upload": "^2.0.4"
|
||||
"@uppy/xhr-upload": "^2.0.4",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"handlebars": "^4.7.0",
|
||||
"truth-helpers": "^1.0.0",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
"start": "ember serve"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0"
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
"start": "ember serve"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0"
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
"discourse-common": "^1.0.0",
|
||||
"discourse-hbr": "^1.0.0",
|
||||
"discourse-widget-hbs": "^1.0.0",
|
||||
"ember-auto-import": "^1.12.0",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-buffered-proxy": "^2.0.0-beta.0",
|
||||
"ember-cli": "~3.25.3",
|
||||
"ember-cli-app-version": "^4.0.0",
|
||||
|
@ -44,7 +44,7 @@
|
|||
"ember-cli-inject-live-reload": "^2.0.1",
|
||||
"ember-cli-sri": "^2.1.1",
|
||||
"ember-cli-terser": "^4.0.1",
|
||||
"ember-exam": "6.1.0",
|
||||
"ember-exam": "^7.0.1",
|
||||
"ember-export-application-global": "^2.0.1",
|
||||
"ember-load-initializers": "^2.1.1",
|
||||
"ember-maybe-import-regenerator": "^0.1.6",
|
||||
|
@ -67,7 +67,8 @@
|
|||
"sass": "^1.32.8",
|
||||
"select-kit": "^1.0.0",
|
||||
"sinon": "^9.2.0",
|
||||
"virtual-dom": "^2.1.1"
|
||||
"virtual-dom": "^2.1.1",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "12.* || 14.* || >= 16",
|
||||
|
@ -84,6 +85,6 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"ember-exam": "6.1.0"
|
||||
"ember-exam": "^7.0.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,10 +15,11 @@
|
|||
"start": "ember serve"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"xss": "^1.0.8"
|
||||
"xss": "^1.0.8",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
"dependencies": {
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"ember-auto-import": "^1.5.3"
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
|
@ -15,9 +15,10 @@
|
|||
"start": "ember serve"
|
||||
},
|
||||
"dependencies": {
|
||||
"ember-auto-import": "^1.5.3",
|
||||
"ember-auto-import": "^2.2.4",
|
||||
"ember-cli-babel": "^7.13.0",
|
||||
"ember-cli-htmlbars": "^4.2.0"
|
||||
"ember-cli-htmlbars": "^4.2.0",
|
||||
"webpack": "^5.67.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ember/optional-features": "^1.1.0",
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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)
|
||||
|
|
|
@ -4,7 +4,7 @@ module QunitHelper
|
|||
|
||||
def vendor_theme_tests
|
||||
return preload_script("vendor-theme-tests") if @legacy_ember
|
||||
preload_script("vendor")
|
||||
preload_vendor_scripts
|
||||
end
|
||||
|
||||
def support_bundles
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<%- if ExtraLocalesController.client_overrides_exist? %>
|
||||
<%= preload_script_url ExtraLocalesController.url('overrides') %>
|
||||
<%- end %>
|
||||
<%= preload_script "vendor" %>
|
||||
<%= preload_vendor_scripts %>
|
||||
<%= preload_script "application" %>
|
||||
<%- Discourse.find_plugin_js_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, request: request).each do |file| %>
|
||||
<%= preload_script file %>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>
|
||||
<%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %>
|
||||
<%= preload_script "locales/#{I18n.locale}" %>
|
||||
<%= preload_script "vendor" %>
|
||||
<%= preload_vendor_scripts %>
|
||||
<%= preload_script "application" %>
|
||||
<%= preload_script "admin" %>
|
||||
<%= preload_script "discourse/tests/test-support-rails" %>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
|
||||
<%- content_for(:no_ember_head) do %>
|
||||
<%= preload_script "vendor" %>
|
||||
<%= preload_vendor_scripts %>
|
||||
<%= render_google_universal_analytics_code %>
|
||||
<%= tag.meta id: 'data-activate-account', data: { path: path('/session/hp') } %>
|
||||
<%- end %>
|
||||
|
|
|
@ -245,7 +245,7 @@ def copy_ember_cli_assets
|
|||
files = {}
|
||||
|
||||
log_task_duration('ember build -prod') {
|
||||
unless system("yarn --cwd #{ember_dir} run ember build -prod")
|
||||
unless system("NODE_OPTIONS='--max-old-space-size=2048' yarn --cwd #{ember_dir} run ember build -prod")
|
||||
STDERR.puts "Error running ember build"
|
||||
exit 1
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue