PERF: Update ember-auto-import (#15814)

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 commit is contained in:
David Taylor 2022-02-04 11:00:51 +00:00 committed by GitHub
parent f3467ee673
commit f4c6a61855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 1737 additions and 120 deletions

View File

@ -15,10 +15,11 @@
"start": "ember serve" "start": "ember serve"
}, },
"dependencies": { "dependencies": {
"ember-auto-import": "^1.5.3", "ember-auto-import": "^2.2.4",
"ember-cli-babel": "^7.13.0", "ember-cli-babel": "^7.13.0",
"ember-cli-htmlbars": "^4.2.0", "ember-cli-htmlbars": "^4.2.0",
"xss": "^1.0.8" "xss": "^1.0.8",
"webpack": "^5.67.0"
}, },
"devDependencies": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

View File

@ -15,17 +15,18 @@
"start": "ember serve" "start": "ember serve"
}, },
"dependencies": { "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": "^2.0.4",
"@uppy/aws-s3-multipart": "^2.1.0", "@uppy/aws-s3-multipart": "^2.1.0",
"@uppy/core": "^2.1.0", "@uppy/core": "^2.1.0",
"@uppy/drop-target": "^1.1.0", "@uppy/drop-target": "^1.1.0",
"@uppy/utils": "^4.0.3", "@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": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

View File

@ -15,9 +15,10 @@
"start": "ember serve" "start": "ember serve"
}, },
"dependencies": { "dependencies": {
"ember-auto-import": "^1.5.3", "ember-auto-import": "^2.2.4",
"ember-cli-babel": "^7.13.0", "ember-cli-babel": "^7.13.0",
"ember-cli-htmlbars": "^4.2.0" "ember-cli-htmlbars": "^4.2.0",
"webpack": "^5.67.0"
}, },
"devDependencies": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

View File

@ -15,9 +15,10 @@
"start": "ember serve" "start": "ember serve"
}, },
"dependencies": { "dependencies": {
"ember-auto-import": "^1.5.3", "ember-auto-import": "^2.2.4",
"ember-cli-babel": "^7.13.0", "ember-cli-babel": "^7.13.0",
"ember-cli-htmlbars": "^4.2.0" "ember-cli-htmlbars": "^4.2.0",
"webpack": "^5.67.0"
}, },
"devDependencies": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

View File

@ -34,7 +34,7 @@
"discourse-common": "^1.0.0", "discourse-common": "^1.0.0",
"discourse-hbr": "^1.0.0", "discourse-hbr": "^1.0.0",
"discourse-widget-hbs": "^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-buffered-proxy": "^2.0.0-beta.0",
"ember-cli": "~3.25.3", "ember-cli": "~3.25.3",
"ember-cli-app-version": "^4.0.0", "ember-cli-app-version": "^4.0.0",
@ -44,7 +44,7 @@
"ember-cli-inject-live-reload": "^2.0.1", "ember-cli-inject-live-reload": "^2.0.1",
"ember-cli-sri": "^2.1.1", "ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.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-export-application-global": "^2.0.1",
"ember-load-initializers": "^2.1.1", "ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6", "ember-maybe-import-regenerator": "^0.1.6",
@ -67,7 +67,8 @@
"sass": "^1.32.8", "sass": "^1.32.8",
"select-kit": "^1.0.0", "select-kit": "^1.0.0",
"sinon": "^9.2.0", "sinon": "^9.2.0",
"virtual-dom": "^2.1.1" "virtual-dom": "^2.1.1",
"webpack": "^5.67.0"
}, },
"engines": { "engines": {
"node": "12.* || 14.* || >= 16", "node": "12.* || 14.* || >= 16",
@ -84,6 +85,6 @@
] ]
}, },
"devDependencies": { "devDependencies": {
"ember-exam": "6.1.0" "ember-exam": "^7.0.1"
} }
} }

View File

@ -15,10 +15,11 @@
"start": "ember serve" "start": "ember serve"
}, },
"dependencies": { "dependencies": {
"ember-auto-import": "^1.5.3", "ember-auto-import": "^2.2.4",
"ember-cli-babel": "^7.13.0", "ember-cli-babel": "^7.13.0",
"ember-cli-htmlbars": "^4.2.0", "ember-cli-htmlbars": "^4.2.0",
"xss": "^1.0.8" "xss": "^1.0.8",
"webpack": "^5.67.0"
}, },
"devDependencies": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

View File

@ -17,7 +17,8 @@
"dependencies": { "dependencies": {
"ember-cli-babel": "^7.13.0", "ember-cli-babel": "^7.13.0",
"ember-cli-htmlbars": "^4.2.0", "ember-cli-htmlbars": "^4.2.0",
"ember-auto-import": "^1.5.3" "ember-auto-import": "^2.2.4",
"webpack": "^5.67.0"
}, },
"devDependencies": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

View File

@ -15,9 +15,10 @@
"start": "ember serve" "start": "ember serve"
}, },
"dependencies": { "dependencies": {
"ember-auto-import": "^1.5.3", "ember-auto-import": "^2.2.4",
"ember-cli-babel": "^7.13.0", "ember-cli-babel": "^7.13.0",
"ember-cli-htmlbars": "^4.2.0" "ember-cli-htmlbars": "^4.2.0",
"webpack": "^5.67.0"
}, },
"devDependencies": { "devDependencies": {
"@ember/optional-features": "^1.1.0", "@ember/optional-features": "^1.1.0",

File diff suppressed because it is too large Load Diff

View File

@ -135,6 +135,22 @@ module ApplicationHelper
path path
end 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) def preload_script(script)
path = script_asset_path(script) path = script_asset_path(script)
preload_script_url(path) preload_script_url(path)

View File

@ -29,7 +29,7 @@
<%- if ExtraLocalesController.client_overrides_exist? %> <%- if ExtraLocalesController.client_overrides_exist? %>
<%= preload_script_url ExtraLocalesController.url('overrides') %> <%= preload_script_url ExtraLocalesController.url('overrides') %>
<%- end %> <%- end %>
<%= preload_script "vendor" %> <%= preload_vendor_scripts %>
<%= preload_script "application" %> <%= preload_script "application" %>
<%- Discourse.find_plugin_js_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, request: request).each do |file| %> <%- Discourse.find_plugin_js_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, request: request).each do |file| %>
<%= preload_script file %> <%= preload_script file %>

View File

@ -6,7 +6,7 @@
<%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %> <%= discourse_stylesheet_link_tag(:desktop, theme_id: nil) %>
<%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %> <%= discourse_stylesheet_link_tag(:test_helper, theme_id: nil) %>
<%= preload_script "locales/#{I18n.locale}" %> <%= preload_script "locales/#{I18n.locale}" %>
<%= preload_script "vendor" %> <%= preload_vendor_scripts %>
<%= preload_script "application" %> <%= preload_script "application" %>
<%= preload_script "admin" %> <%= preload_script "admin" %>
<%= preload_script "discourse/tests/test-support-rails" %> <%= preload_script "discourse/tests/test-support-rails" %>

View File

@ -10,7 +10,7 @@
</div> </div>
<%- content_for(:no_ember_head) do %> <%- content_for(:no_ember_head) do %>
<%= preload_script "vendor" %> <%= preload_vendor_scripts %>
<%= render_google_universal_analytics_code %> <%= render_google_universal_analytics_code %>
<%= tag.meta id: 'data-activate-account', data: { path: path('/session/hp') } %> <%= tag.meta id: 'data-activate-account', data: { path: path('/session/hp') } %>
<%- end %> <%- end %>