-
Notifications
You must be signed in to change notification settings - Fork 216
CHECKOUT-9450: Lazy load payment strategies through essential build #2989
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
base: master
Are you sure you want to change the base?
Changes from all commits
5c5808e
8803ce0
9fa9054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/packages/core/src/generated/*.ts | ||
/packages/core/src/generated/**/*.ts | ||
/dist/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,10 +19,30 @@ | |
} | ||
] | ||
}, | ||
"build-analyze": { | ||
"executor": "@nrwl/workspace:run-commands", | ||
"options": { | ||
"commands": [ | ||
"webpack --config webpack.config.js --config-name esm --profile --json > webpack-stats.json", | ||
"webpack-bundle-analyzer webpack-stats.json dist --default-sizes gzip" | ||
], | ||
"parallel": false | ||
}, | ||
"dependsOn": [ | ||
{ | ||
"target": "generate", | ||
"projects": "self" | ||
}, | ||
{ | ||
"target": "build", | ||
"projects": "dependencies" | ||
} | ||
] | ||
}, | ||
"build-watch": { | ||
"executor": "@nrwl/workspace:run-commands", | ||
"options": { | ||
"command": "webpack --config webpack.config.js --config-name cjs --watch --progress" | ||
"command": "webpack --config webpack.config.js --config-name esm --watch --progress" | ||
}, | ||
"dependsOn": [ | ||
{ | ||
|
@@ -63,6 +83,7 @@ | |
"commands": [ | ||
"tsc --outDir ../../temp --declaration --emitDeclarationOnly", | ||
"api-extractor run --config api-extractor/checkout-sdk.json & api-extractor run --config api-extractor/checkout-button.json & api-extractor run --config api-extractor/embedded-checkout.json & api-extractor run --config api-extractor/internal-mappers.json", | ||
"find src/generated/integrations -name 'api-extractor.json' | xargs -I {} -P 8 sh -c 'cd \"$(dirname \"{}\")\" && npx api-extractor run --config api-extractor.json'", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since each payment integration has is own entry point, e.g.: |
||
"rm -rf ../../temp", | ||
"nx run hosted-form-v2:build-dts" | ||
] | ||
|
@@ -74,7 +95,7 @@ | |
"cwd": "packages/core", | ||
"parallel": false, | ||
"commands": [ | ||
"mkdir -p src/generated && cp ../../dist/checkout-sdk.d.ts src/generated/checkout-sdk.d.ts", | ||
"mkdir -p src/generated && cp ../../dist/types/checkout-sdk.d.ts src/generated/checkout-sdk.d.ts", | ||
"typedoc --plugin typedoc-plugin-markdown --options typedoc.json --tsconfig tsconfig.json src/generated/checkout-sdk.d.ts" | ||
] | ||
}, | ||
|
@@ -118,6 +139,7 @@ | |
"executor": "@nrwl/workspace:run-commands", | ||
"options": { | ||
"commands": [ | ||
"rm -rf packages/core/src/generated", | ||
"npx nx generate @bigcommerce/checkout-sdk/workspace-tools:auto-export --projectName=core", | ||
"npx nx generate @bigcommerce/checkout-sdk/workspace-tools:extend-interface --projectName=core", | ||
"npx nx generate @bigcommerce/checkout-sdk/workspace-tools:create-enum --projectName=core" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ import { | |
WorkerExtensionMessenger, | ||
} from '../extension'; | ||
import { FormFieldsActionCreator, FormFieldsRequestSender } from '../form'; | ||
import * as defaultPaymentStrategyFactories from '../generated/payment-strategies'; | ||
import * as customerStrategyFactories from '../generated/customer-strategies'; | ||
import * as paymentStrategyFactories from '../generated/payment-strategies'; | ||
import { CountryActionCreator, CountryRequestSender } from '../geography'; | ||
import { OrderActionCreator, OrderRequestSender } from '../order'; | ||
import { | ||
|
@@ -136,12 +137,20 @@ export default function createCheckoutService(options?: CheckoutServiceOptions): | |
formFieldsActionCreator, | ||
); | ||
const paymentIntegrationService = createPaymentIntegrationService(store); | ||
|
||
const registryV2 = createPaymentStrategyRegistryV2( | ||
paymentIntegrationService, | ||
defaultPaymentStrategyFactories, | ||
paymentStrategyFactories, | ||
// TODO: Replace once CHECKOUT-9450.lazy_load_payment_strategies experiment is rolled out | ||
// process.env.ESSENTIAL_BUILD ? {} : paymentStrategyFactories, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Payment integration strategies will be excluded from the essential build once the experiment is fully rolled out. During the build phase, TerserJS will remove |
||
{ useFallback: true }, | ||
); | ||
const customerRegistryV2 = createCustomerStrategyRegistryV2(paymentIntegrationService); | ||
const customerRegistryV2 = createCustomerStrategyRegistryV2( | ||
paymentIntegrationService, | ||
customerStrategyFactories, | ||
// TODO: Replace once CHECKOUT-9450.lazy_load_payment_strategies experiment is rolled out | ||
// process.env.ESSENTIAL_BUILD ? {} : customerStrategyFactories, | ||
); | ||
const extensionActionCreator = new ExtensionActionCreator( | ||
new ExtensionRequestSender(requestSender), | ||
); | ||
|
@@ -174,6 +183,7 @@ export default function createCheckoutService(options?: CheckoutServiceOptions): | |
new CustomerStrategyActionCreator( | ||
createCustomerStrategyRegistry(store, requestSender, locale), | ||
customerRegistryV2, | ||
paymentIntegrationService, | ||
), | ||
new ErrorActionCreator(), | ||
new GiftCertificateActionCreator(new GiftCertificateRequestSender(requestSender)), | ||
|
@@ -191,6 +201,7 @@ export default function createCheckoutService(options?: CheckoutServiceOptions): | |
registryV2, | ||
orderActionCreator, | ||
spamProtectionActionCreator, | ||
paymentIntegrationService, | ||
), | ||
new PickupOptionActionCreator(new PickupOptionRequestSender(requestSender)), | ||
new ShippingCountryActionCreator( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface Sentry { | ||
captureMessage(message: string): void; | ||
} | ||
|
||
export interface SentryWindow extends Window { | ||
Sentry?: Sentry; | ||
} |
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.
This change sets up multiple entry points for the package. See https://docs.npmjs.com/cli/v11/configuring-npm/package-json#exports