feat(targets): Add target for editing UPWARD definitions (DRAFT) #2459
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.
Description
Currently, UPWARD is extensible via a very simple "shallow merge" behavior. In Webpack config, in the
specialflags, you can setupward: truefor a package (e.g.@magento/venia-ui) to make Buildpack find anupward.ymlin that package and merge it into the final UPWARD definition for the project.This doesn't permit more sophisticated UPWARD transformations, which could get real real interesting.
It's possible to use low-level Webpack access to find and modify the UPWARD definition, but it's both inefficient and verbose. Here is an example of such an implementation.
With the
transformUpwardTarget implemented in this PR, we can do the same thing as the file above, but much prettier:Related Issue
None. Do not merge yet: leave this PR in draft as an example of a PR to support a desired target.
Acceptance
Verification Stakeholders
Community!
Verification Steps
yarnand thenyarn studiolink </path/to/pwa-studio-branch>packages/upward-csp/package.jsonand change"intercept": "./intercept-upward-file"to"intercept": "./intercept-upward-target".BUILDBUS_DEPS_ADDITIONAL=@magento-research/pwa-upward-csp yarn run build && yarn run stage:venia