SalesforceCommerceCloud / pwa-kit

React-based JavaScript frontend framework to create a progressive web app (PWA) storefront for Salesforce B2C Commerce.
https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pwa-kit-overview.html
BSD 3-Clause "New" or "Revised" License
285 stars 138 forks source link

[App Extensibility] Handle when an extension does not have its dependencies loaded (@W-16561401@) #2134

Closed vmarta closed 4 days ago

vmarta commented 1 week ago

This PR checks and validates at build time that the extensions and their dependencies are loaded correctly. If there are some missing or disabled dependencies, then we will crash the app with a descriptive error message.

How to test-drive the PR

The typescript-minimal project installs 2 sample extensions. The 2nd sample extension depends on the 1st one. Let's see what happens if the dependency is disabled/deleted.

  1. Revert the last commit to bring back the sample extensions.
  2. npm ci at the monorepo root
  3. Tweak the extensions config found in typescript-minimal's package.json, such that the 1st sample extension is disabled or deleted.
  4. Then try running npm start or npm run build and you'll see the results as follows:
npm start

> typescript-minimal@4.0.0-dev start
> pwa-kit-dev start

info: Validating app extensions...
error: Extension(s) missing or disabled: @salesforce/extension-sample, as required by @salesforce/extension-sample-2
error: Please double-check your configuration.
npm run build

> typescript-minimal@4.0.0-dev build
> pwa-kit-dev build

info: Validating app extensions...
error: Extension(s) missing or disabled: @salesforce/extension-sample, as required by @salesforce/extension-sample-2
error: Please double-check your configuration.