Conversation
|
A thought occurs to me: As they describe in their "old" (current) documentation, it's recommended to output all chunks at once, to best deduplicate shared groups of chunks.
This could work well with |
|
That sounds good to me 👍🏼 |
|
Nice, this is super nifty!
Yeah, I wouldn't expect that to be a problem either. |
|
Started looking at shifting everything to use
|
3a96209
ae495a4
e046e1a, deferring execution until |
|
Another interesting edge case: Some packs rely on a specific order of scripts being loaded, e.g. Ideally we'd have stronger dependencies defined, using imports. Another option similar to e046e1a would be to wait 'til page load to call the constructor. I'd also thought maybe it'd be as easy as moving Next best option I considered for a solution is to allow the method to receive an option to control the order that the pack is enqueued (a |
zachmargolis
left a comment
There was a problem hiding this comment.
LGTM some small nits
**Why**: - Since it is the default behavior as of the upcoming Webpacker 6+ release, it will make a future upgrade easier. - See: https://github.com/rails/webpacker/blob/1aca8aa/6_0_upgrade.md - It will allow for reuse of large shared dependencies (e.g. using React outside of the document capture pack without bundling a new copy of React into each pack where it is used). - This effort was prompted by a desire to use React outside the document capture screen (specifically to reuse the existing Alert React component) - Conceptually well-aligned to javascript_pack_tag_once, facilitating eventual migration to render all scripts once at the bottom of each page. - See: https://web.dev/render-blocking-resources/
**Why**: Split chunks will output many separate scripts, but there should be at most one with name starting with each chunk. Others will be prefixed either `runtime~` or `vendors~`.
**Why**: Avoid issue where using javascript_packs_with_chunks_tag multiple times inlined may cause duplicate chunks tags to be rendered.
**Why**: Session timeout makes synchronous reference to LoginGov window globals which are only assigned by packs
**Why**: This JavaScript is inlined prior to pack output. As such, LoginGov global is not yet assigned. Waiting until page has fully loaded provides assurance that those scripts will have then been loaded.
**Why**: More granular control over order of script enqueuing, in cases such as layouts where layout template would be rendered after partial, and scripts which occur _before_ the partial in markup would still enqueue scripts _after_ the partial.
**Why**: See 67ef74469
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
d1d1263 to
aea5b1c
Compare
**Why:** So that users are redirected automatically when completing SAML authentication. In #4553, all JavaScript packs were changed to use the `javascript_packs_tag_once` helper, which is intended to be used in rendering all JavaScript chunks once at the bottom of the page. However, this must be complemented by a call to the `render_javascript_pack_once_tags` helper. This exists in the base template, but since the `saml_post_binding` view doesn't inherit from this template, the helper is never called, and therefore the script is never added to the page. Since we don't need to worry as much about deduplicating script chunks on this page, we can simply call directly to Webpacker's `javascript_packs_with_chunks_tag` helper.
**Why:** So that users are redirected automatically when completing SAML authentication. In #4553, all JavaScript packs were changed to use the `javascript_packs_tag_once` helper, which is intended to be used in rendering all JavaScript chunks once at the bottom of the page. However, this must be complemented by a call to the `render_javascript_pack_once_tags` helper. This exists in the base template, but since the `saml_post_binding` view doesn't inherit from this template, the helper is never called, and therefore the script is never added to the page. Since we don't need to worry as much about deduplicating script chunks on this page, we can simply call directly to Webpacker's `javascript_packs_with_chunks_tag` helper.
Why: