Install dependencies for the workspace
yarn installAll commands below need to be run in the context of the checkout-sdk package in the ./sdk folder unless specified otherwise. Read more about context here.
Running in dev mode using the immutable-devnet network:
yarn start:devRunning in sandbox/production mode using the immutable-testnet/mainnet network based on the environment value set for the SANDBOX_CONFIGURATION config object in the ./sdk/src/sdk.ts file:
yarn startRunning the Checkout SDK Sample App with the Checkout SDK supporting hot reloading:
# Run the Checkout SDK first
# Context: checkout-sdk in ./sdk
yarn start
# Run the Checkout SDK Sample App in a new terminal
# Context: checkout-sdk-sample-app in ./sdk-sample-app
yarn startBuilding to the ./sdk/dist directory for dev environment:
yarn build:devBuilding to the ./sdk/dist directory for sandbox/production environment:
yarn buildRunning all jest tests:
yarn testRunning changed tests on save in watch mode:
yarn test:watchLinting:
yarn lintLinting and attempting to auto-fix issues:
yarn lint:fixTypechecking:
yarn typecheckGenerate Typescript API documentation (viewable in the newly generated docs folder at ./sdk/docs/README.md):
yarn docsAll commands below need to be run in the context of the checkout-widgets package in the ./widgets-lib folder unless specified otherwise. Read more about context here.
Running in dev mode (widgets-lib depends upon checkout-sdk):
# Run the Checkout SDK first
# Context: checkout-sdk in ./sdk
yarn start:dev
# Run the Widgets Library in a new terminal
# Context: checkout-widgets in ./widgets-lib
yarn startRunning the Widgets Sample App with the Widgets Library supporting hot reloading:
# Run the above two commands first
# ...
# Run the Widgets Sample App in a new terminal
# Context: checkout-widgets-sample-app in ./widgets-sample-app
yarn startRead more about running locally here.
Building the Widgets Library to the ./widgets-lib/dist directory:
yarn buildBuilding the Widgets Library and outputting a bundle visualizer:
yarn build:analyzeRunning all jest tests:
yarn testRunning changed jest tests on save in watch mode:
yarn test:watchLinting:
yarn lintLinting and attempting to auto-fix issues:
yarn lint:fixTypechecking:
yarn typecheckWhen you develop locally, the widgets-sample-app installs and imports the widgets as an es module. import { WidgetsFactory} from '@imtbl/checkout-widgets' This helps local development with hot reloading. (it takes a lot longer to rebuild and minify a browser bundle).
In production however, the widgets-lib package is built as a browser bundle and is dynamically included in the DOM when you call await checkout.widgets().
To test this setup locally and force the widgets bundle to be loaded from localhost you will need to run
# Run the Checkout SDK first in local dev mode
# Context: checkout-sdk in ./sdk
yarn start:local# Build the Widgets Library in a new terminal in local mode
# Context: checkout-widgets in ./widgets-lib
yarn build:local# Run the Widgets Sample App in a new terminal
# Context: checkout-widgets-sample-app in ./widgets-sample-app
yarn startYou will then need to make sure that you replace your creation of a new WidgetsFactory() with a call to await checkout.widgets() within the sample app. This will pull in the built widgets.js bundle dynamically, but from your local filesystem.
In a production release, this script is loaded from a CDN. We are currently using https://cdn.jsdelivr.net/npm/@imtbl/sdk/dist/browser/checkout/widgets.js
─ checkout
│
├── sdk - Checkout SDK
│
├── sdk-sample-app - Sample app where the Checkout SDK is consumed
│
├── widgets-lib - Checkout widgets
│
├── widgets-sample-app - Sample app where the Checkout Widgets are consumed
│
└── README.md