DEV: Improve strategy for identifying ember-cli JS chunks (#23336)

Our Ember build compiles assets into multiple chunks. In the past, we used the output from `ember-auto-import-chunks-json-generator` to give Rails a map of those chunks. However, that addon is specific to ember-auto-import, and is not compatible with Embroider.

Instead, we can switch to parsing the html files which are output by ember-cli. These are guaranteed to have the correct JS files in the correct place. A `<discourse-chunked-script>` will allow us to easily identify which chunks belong to which entrypoint.

In future, as we update more entrypoints to be compiled by Embroider/Webpack, we can easily introduce new wrappers.
This commit is contained in:
David Taylor
2023-08-30 18:47:06 +01:00
committed by GitHub
parent a97dcd8564
commit 2c58d456dd
6 changed files with 44 additions and 30 deletions

View File

@ -133,10 +133,12 @@ module ApplicationHelper
end
def preload_script(script)
scripts = [script]
scripts = []
if chunks = EmberCli.script_chunks[script]
scripts.push(*chunks)
else
scripts.push(script)
end
scripts