Use Webpack manifest to associate asset references per pack#6198
Merged
Use Webpack manifest to associate asset references per pack#6198
Conversation
aduth
commented
Apr 14, 2022
**Why**: Since our current approach to list assets required per pack is not scalable, and does not account. changelog: Internal, Build, Generate asset manifest during JavaScript build
Because there's nil-safe navigation, so possible nil values
bf78364 to
197533c
Compare
https: //github.com//pull/6198#discussion_r850804108 Co-Authored-By: Zach Margolis <zbmargolis@gmail.com>
**Why**: Avoid risks and complication of dealing with executable script tag
Contributor
Author
1. Parameter not typed (any) 2. Inferred return value is "string", when it can be undefined
aduth
commented
Apr 15, 2022
| def javascript_assets_tag(*names) | ||
| assets = AssetSources.get_assets(*names) | ||
| if assets.present? | ||
| asset_map = assets.index_with { |path| asset_path(path) } |
Contributor
Author
There was a problem hiding this comment.
I expect I'll need to revisit this in future work, where we'll want to use this for the design system icon sprite, which can't be loaded across domains, so we'll need to have a way to pass host: asset_host like we do in IconComponent:
identity-idp/app/components/icon_component.rb
Line 261 in 5a8af56
Thinking we might need to have some sort of allowlist, e.g.
Suggested change
| asset_map = assets.index_with { |path| asset_path(path) } | |
| asset_map = assets.index_with do |path| | |
| asset_path(path, host: SAME_ORIGIN_ASSETS.include?(path) && asset_host) | |
| end |
(host option uses falsey assignment for defaulting)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why: Since our current approach to list assets required per pack is not scalable, and does not account for packs other than
document-capture, nor would it support assets deeply referenced via shareable packages (e.g.@18f/identity-components).What:
getAssetPathasset_path, and assigned to a window globalgetAssetPathpull the mapped path from the window globalTesting Instructions:
Ensure there are no regressions to the use of images in the document capture step, e.g. the "warning" icon after a failed submission, or the ID card animated SVG loading interstitial.