-
Notifications
You must be signed in to change notification settings - Fork 73
refactor: scoping of UPE utilities at checkout #11230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
|
Size Change: -570 B (0%) Total Size: 929 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors checkout utilities to improve bundle separation between classic (shortcode) and blocks checkout implementations. The refactoring prevents the blocks checkout bundle from importing classic-specific utilities, reducing bundle size.
Changes:
- Moved classic-specific UPE utilities from shared location to
client/checkout/classic/upe-utils.js - Extracted shared
validateElementsfunction to its own utility file - Created blocks-specific utilities in
client/checkout/blocks/utils.js - Moved constants to appropriate scopes (classic vs shared)
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
client/checkout/woopay/express-button/woopay-express-checkout-payment-method.js |
Moved PAYMENT_METHOD_NAME_WOOPAY_EXPRESS_CHECKOUT constant locally since it's only used in this file |
client/checkout/utils/validate-elements.js |
New shared utility file containing validateElements function used by both classic and blocks checkout |
client/checkout/utils/upe.js |
Removed classic-specific utilities, keeping only shared functions (getTerms, isLinkEnabled, getPaymentMethodTypes) |
client/checkout/utils/__tests__/upe.test.js |
Updated tests to only cover remaining shared utilities |
client/checkout/constants.js |
Removed classic-specific constants that were moved to classic/constants.js |
client/checkout/classic/upe-utils.js |
New file containing all classic-specific UPE utilities moved from shared location |
client/checkout/classic/payment-processing.js |
Updated imports to use new file locations for classic utilities and shared validateElements |
client/checkout/classic/event-handlers.js |
Updated imports to use classic-specific utilities and constants |
client/checkout/classic/constants.js |
New file containing classic-specific constants like SHORTCODE_BILLING_ADDRESS_FIELDS |
client/checkout/classic/__tests__/upe-utils.test.js |
New test file with all tests for classic-specific utilities |
client/checkout/classic/__tests__/payment-processing.test.js |
Updated mock imports to reflect new file structure |
client/checkout/blocks/utils.js |
Added blocks-specific getStripeElementOptions function previously in shared utilities |
client/checkout/blocks/payment-processor.js |
Updated imports to use blocks-specific utilities and shared validateElements |
client/checkout/blocks/__tests__/utils.test.js |
New test file for blocks-specific utilities |
client/checkout/blocks/__tests__/payment-processor.test.js |
Updated mocks to reflect new import locations |
changelog/poc-upe-utilities-scoping |
Added changelog entry for this refactoring |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fixes #
Changes proposed in this Pull Request
Refactoring checkout utilities to improve bundle separation between classic (shortcode) and blocks checkout.
The blocks checkout bundle was importing
validateElementsfromclassic/payment-processing.js, which caused the entire file to be bundled into the blocks checkout.Testing instructions
npm run changelogto add a changelog file, choosepatchto leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge