Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
02e1334
initial implementation of extension seo url mapping extension
hajinsuha1 Feb 26, 2025
41b34a7
make beforeRouteMatch async
hajinsuha1 Feb 26, 2025
87567d8
generate component map from react-sdk util function
hajinsuha1 Feb 26, 2025
0a42f90
use a component map that maps resource type to component display name
hajinsuha1 Feb 27, 2025
9b1dada
move logic from beforeRouteMatch to extendRoutes
hajinsuha1 Feb 27, 2025
b8505d0
make extendRoutes async
hajinsuha1 Feb 27, 2025
74ea27a
pass request to extendRoutes
hajinsuha1 Mar 3, 2025
5988996
add route serialization
hajinsuha1 Mar 3, 2025
61839ff
make category urlMappings work
hajinsuha1 Mar 3, 2025
1a8d1be
make urlMapping resourceType product work
hajinsuha1 Mar 4, 2025
8380df6
cleanup
hajinsuha1 Mar 4, 2025
182f7b6
move serializing to pwa-kit-react-sdk
hajinsuha1 Mar 4, 2025
babf5ab
move transformUrlMappingToRoute from pwa-kit-react-sdk to extension-s…
hajinsuha1 Mar 5, 2025
3651f4e
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 Mar 5, 2025
efdc0c5
cleanup
hajinsuha1 Mar 5, 2025
2d1031f
update package.json and package-lock.json in template-typescript-minimal
hajinsuha1 Mar 5, 2025
5e45dac
attempt to fix component not loading with props on server side
hajinsuha1 Mar 5, 2025
f178dec
implement route serialization/deserialization
hajinsuha1 Mar 5, 2025
cfd82eb
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 Mar 5, 2025
7b8b80b
initial pass at implementing route serialization via a componentMap
hajinsuha1 Mar 7, 2025
4f30443
update error handling message format
hajinsuha1 Mar 7, 2025
c78b81b
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 Mar 7, 2025
55c4415
cleanup and fix getRoutes to not duplicate routes
hajinsuha1 Mar 7, 2025
5da9d8e
Convert extendRoutes to an async method
vmarta Mar 8, 2025
4d13fe3
create a helper function generateComponentMapFromModules
hajinsuha1 Mar 10, 2025
8a54875
Add todos
vmarta Mar 10, 2025
4604d76
Temporarily modify the typescript-minimal project
vmarta Mar 10, 2025
e6542fc
initial impl of adding base template components to component map
hajinsuha1 Mar 10, 2025
7a1f51f
Minor refactoring
vmarta Mar 10, 2025
ddb88d2
Call every extension's route function in parallel
vmarta Mar 10, 2025
138f44b
create a prefixDisplayName utils
hajinsuha1 Mar 11, 2025
3bfa646
update error handling
hajinsuha1 Mar 11, 2025
2054078
fix deserialization of components from pwa-kit-react-sdk
hajinsuha1 Mar 11, 2025
a547b24
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 11, 2025
63a9d1f
merge
hajinsuha1 Mar 11, 2025
d90c79c
initial implementation of serialize/deserialize
hajinsuha1 Mar 12, 2025
c67fefa
cleanup
hajinsuha1 Mar 12, 2025
af9f3df
make serialize() and getComponentMap() synchronous
hajinsuha1 Mar 13, 2025
b002c86
Pass in the request path
vmarta Mar 13, 2025
bd74cf8
cache getRoutes using CacheResult decorator
hajinsuha1 Mar 14, 2025
b84c8c3
move deserialization logic to constructor of ApplicationExtension
hajinsuha1 Mar 14, 2025
3a9f90d
call this.getComponentMap within deserialize and fix typing
hajinsuha1 Mar 14, 2025
4a3a6ce
cleanup serialize logic
hajinsuha1 Mar 14, 2025
6d92af9
Explore passing in locals and how to manage access token
vmarta Mar 14, 2025
9f6c055
Remove extendRoutes from the API
vmarta Mar 15, 2025
6d5fb39
Allow configuring of the auth property name in locals
vmarta Mar 15, 2025
0115d21
comments + create DeserializedExtension type
hajinsuha1 Mar 17, 2025
fa85193
make getComponentMap abstract
hajinsuha1 Mar 17, 2025
040e3f1
add ComponentMap type to getComponentMap method in ChakraStorefront a…
hajinsuha1 Mar 17, 2025
86a78ed
add displayName to StoreLocatorPage
hajinsuha1 Mar 17, 2025
0a7e855
Rename the property in locals
vmarta Mar 17, 2025
9acff92
add unit tests for cacheResult
hajinsuha1 Mar 17, 2025
c5d924b
Create a new extension for a better example
vmarta Mar 17, 2025
2206dd5
Add some console logs
vmarta Mar 17, 2025
392387a
refactor Switch component to use RoutesProvider and create RoutesCons…
hajinsuha1 Mar 17, 2025
0c1bd41
update CacheResult decorator to support async methods and modify test…
hajinsuha1 Mar 17, 2025
08e72bd
enhance CacheResult decorator to support both async and sync methods …
hajinsuha1 Mar 18, 2025
0dbbb34
refactor getRoutes method to support both sync and async returns and …
hajinsuha1 Mar 18, 2025
8324897
refactor ApplicationExtension to enforce getComponentMap() for async …
hajinsuha1 Mar 18, 2025
5586726
cleanup ApplicationExtension and apply CacheResult to getRoutes metho…
hajinsuha1 Mar 18, 2025
645a91f
move CacheResult decorator logic to applyCacheForMethod in Applicatio…
hajinsuha1 Mar 18, 2025
d0ffc37
don't make getComponentMap abstract but make it optional
hajinsuha1 Mar 18, 2025
f97aaed
remove unused ComponentMap import from test files
hajinsuha1 Mar 18, 2025
42879f5
Experiment with having partial route
vmarta Mar 18, 2025
b71c0b9
Experiment with correct way to get app origin
vmarta Mar 18, 2025
bb692bc
Add todo
vmarta Mar 18, 2025
0d2ed3b
Some cleanup
vmarta Mar 18, 2025
35a453e
lint
hajinsuha1 Mar 19, 2025
272639f
cleanup
hajinsuha1 Mar 19, 2025
2067892
Fix the partial route with correct path
vmarta Mar 19, 2025
0e44b84
Remove no longer necessary code
vmarta Mar 19, 2025
1579626
Combine params into a single object
vmarta Mar 19, 2025
806fa87
Remove some console logs
vmarta Mar 19, 2025
85f9516
add async route handling and serialization tests for ApplicationExten…
hajinsuha1 Mar 19, 2025
11b5af3
Add comment to clarify
vmarta Mar 19, 2025
6402e62
handle all condiiton in deserialize and move applyCacheForMethod to a…
hajinsuha1 Mar 19, 2025
e8bba80
refactor: rename getRoutes to getRoutesAsync for clarity and update r…
hajinsuha1 Mar 19, 2025
af93217
refactor: remove isGetRoutesAsync method as it's no longer needed
hajinsuha1 Mar 19, 2025
579bdf3
Implement getRoutes and getRoutesAsync
vmarta Mar 20, 2025
18adf16
Add comment
vmarta Mar 20, 2025
d9b32e2
Add comment
vmarta Mar 20, 2025
4ad2535
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 20, 2025
965a34a
update getRoutesAsync to also return SerializedRoute and serialize to…
hajinsuha1 Mar 20, 2025
6baf649
cleanup decorator and chakra-storefront
hajinsuha1 Mar 20, 2025
5dbe489
update URLMapping.getRoutesAsync and BeforeRouteMatchParams to suppor…
hajinsuha1 Mar 20, 2025
26da1ee
address PR feedback
hajinsuha1 Mar 20, 2025
f1eab7c
update error message
hajinsuha1 Mar 20, 2025
0a1626c
fix cacheMethodResult
hajinsuha1 Mar 20, 2025
c622823
Add type to allow for `componentName` property
vmarta Mar 20, 2025
92a1c9a
fix ApplicationExtension.test.tsx
hajinsuha1 Mar 20, 2025
f615878
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 20, 2025
38e352f
Remove params for `getRoutes`
vmarta Mar 20, 2025
4119cda
Remove params for getRoutes
vmarta Mar 20, 2025
6677213
refactor: update route handling to use RouteProps exclusively and imp…
hajinsuha1 Mar 20, 2025
0058e80
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 20, 2025
fa4540a
refactor: rename GetRoutesParams to GetRoutesAsyncParams for to fix e…
hajinsuha1 Mar 20, 2025
4af8642
update unit tests
hajinsuha1 Mar 20, 2025
7fdd261
Revert "Remove params for `getRoutes`"
vmarta Mar 20, 2025
bcdcea3
Revert "Remove params for getRoutes"
vmarta Mar 20, 2025
7b48662
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 21, 2025
62e0060
reorganize imports for RoutesContext and unit tests
hajinsuha1 Mar 21, 2025
347c486
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 Mar 21, 2025
de121c3
Add isServerSide utility function and corresponding tests
hajinsuha1 Mar 21, 2025
2152142
lint
hajinsuha1 Mar 21, 2025
ab23cd6
[REVERT] temporary logging for testing
hajinsuha1 Mar 21, 2025
5236d90
Remove unused properties from global Window interface in type definit…
hajinsuha1 Mar 21, 2025
131f670
update changelog
hajinsuha1 Mar 21, 2025
6e257cd
Refactor so that extension is the one in control of serialization
vmarta Mar 21, 2025
edcae1d
Update packages/pwa-kit-extension-sdk/src/react/classes/ApplicationEx…
hajinsuha1 Mar 24, 2025
04ee8fb
update unit tests and add error handling
hajinsuha1 Mar 24, 2025
c6be840
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 Mar 24, 2025
c8e8035
lint
hajinsuha1 Mar 24, 2025
88419bf
lint
hajinsuha1 Mar 24, 2025
e9c00dd
lint extension-url-mapping
hajinsuha1 Mar 24, 2025
4d2587a
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 Mar 24, 2025
1de2122
Update comments
vmarta Mar 24, 2025
38425c2
Update tests
vmarta Mar 24, 2025
2f1a48a
rename extension-url-mapping to extension-commerce-bm-seo
hajinsuha1 Mar 24, 2025
2bcbbc2
Update tests
vmarta Mar 24, 2025
7ba4d99
Revert changes to typescript-minimal
vmarta Mar 24, 2025
7c731f2
Merge branch 'feature/extensibility-v2' into vm/async-extendRoutes
vmarta Mar 24, 2025
a2096c3
Update package-lock.json
vmarta Mar 24, 2025
18a566f
Update changelog files
vmarta Mar 24, 2025
0e0edcb
Update readme files
vmarta Mar 24, 2025
422bd78
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 25, 2025
7ed9fbd
Refactor ApplicationExtension tests to use correct component types an…
hajinsuha1 Mar 25, 2025
e08d7ce
Remove extension-url-mapping package and associated files
hajinsuha1 Mar 25, 2025
bab7884
fix unit tests
hajinsuha1 Mar 25, 2025
c594557
Revert "Remove extension-url-mapping package and associated files"
hajinsuha1 Mar 25, 2025
794b0a3
lint
hajinsuha1 Mar 25, 2025
0cd67cc
Revert "Revert changes to typescript-minimal"
hajinsuha1 Mar 25, 2025
54ec28a
remove extension-url-mapping, logging, changes to typescript-minimal
hajinsuha1 Mar 25, 2025
6d7c6a9
update maxSize for build/vendor.js to 353 kB in template-retail-react…
hajinsuha1 Mar 25, 2025
12b071b
update CHANGELOG.md for template-retail-react-app
hajinsuha1 Mar 25, 2025
fc461cd
add ResourceTypeToComponentMap and move functions to utils
hajinsuha1 Mar 25, 2025
5f5de44
Add jsdoc to some types
vmarta Mar 25, 2025
ad8933a
Update packages/pwa-kit-extension-sdk/src/react/classes/ApplicationEx…
hajinsuha1 Mar 26, 2025
f65cf58
address PR feedback (remove unnecessary code)
hajinsuha1 Mar 26, 2025
876b4c2
Revert "remove extension-url-mapping, logging, changes to typescript-…
hajinsuha1 Mar 26, 2025
ad6d337
update ApplicationExtension unit test
hajinsuha1 Mar 26, 2025
f05a70a
Revert "Revert "remove extension-url-mapping, logging, changes to typ…
hajinsuha1 Mar 26, 2025
16f461b
Merge branch 'vm/async-extendRoutes' into route-serialization-to-supp…
hajinsuha1 Mar 26, 2025
7aa5a85
Revert "remove extension-url-mapping, logging, changes to typescript-…
hajinsuha1 Mar 26, 2025
c9a58da
Merge branch 'route-serialization-to-support-shopper-seo-integration'…
hajinsuha1 Mar 28, 2025
b01d659
refactor such that extension-commerce-bm-seo handles deserialization …
hajinsuha1 Mar 31, 2025
0751fd9
refactor serialize and deserialize to be serializeRoutes and deserial…
hajinsuha1 Mar 31, 2025
8017fa6
cleanup beforeRouteMatch
hajinsuha1 Mar 31, 2025
d3b5651
cleanup
hajinsuha1 Mar 31, 2025
07d7da0
address PR feedback
hajinsuha1 Apr 1, 2025
0fe9e28
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 Apr 16, 2025
90fabe5
lint
hajinsuha1 Apr 16, 2025
ef43d50
support redirect url mappings
hajinsuha1 Apr 21, 2025
03dda35
attempt passing props to ProductDetail/ProductList component
hajinsuha1 Apr 21, 2025
a0c8a18
fix placeholder component
hajinsuha1 Apr 22, 2025
5f11e34
refactor to make setup-app more readable
hajinsuha1 Apr 22, 2025
b4a23f2
implementation where PLP and PDP on client side doesn't get props
hajinsuha1 Apr 25, 2025
12e4116
implement option 1 add componentProps to RouteProps and serialize it
hajinsuha1 Apr 25, 2025
ac3cf68
make deserialization work for both extension-seo and regular extensions
hajinsuha1 Apr 29, 2025
9129a42
remove logging
hajinsuha1 Apr 29, 2025
3782fb9
allow extension-seo to work regardless of whether it is before/after …
hajinsuha1 Apr 29, 2025
6ed3ffa
add AsyncRouteProps type
hajinsuha1 Apr 29, 2025
0de2b6a
remove getComponentName utility method
hajinsuha1 Apr 29, 2025
8382e9a
cleanup
hajinsuha1 Apr 29, 2025
a27ce96
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 Apr 29, 2025
0096116
reorganize utils
hajinsuha1 Apr 29, 2025
da93df5
support unit tests
hajinsuha1 Apr 29, 2025
b42d623
add jest.config.js (copied from extension-chakra-store-locator)
hajinsuha1 Apr 29, 2025
ceae1c5
add component-utils unit tests
hajinsuha1 Apr 30, 2025
78837c1
remove path from config and add shopper-seo-utils unit tests
hajinsuha1 Apr 30, 2025
a2113da
initial README.md
hajinsuha1 May 1, 2025
6cfecf0
update README
hajinsuha1 May 2, 2025
613813e
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 May 5, 2025
be17100
hardcode __commerceAPIAuth property in locals and use getAppOrigin fr…
hajinsuha1 May 5, 2025
366c74b
cleanup
hajinsuha1 May 5, 2025
c4a432f
Merge branch 'implement-dynamic-update-routes' of https://github.com/…
hajinsuha1 May 5, 2025
cc4714b
fix type errors
hajinsuha1 May 5, 2025
ade541e
Revert to test changes
hajinsuha1 May 5, 2025
44dcdc7
Revert "Revert to test changes"
hajinsuha1 May 5, 2025
3adf867
cleanup
hajinsuha1 May 5, 2025
4b91cbd
REVERT TO TEST CHANGES
hajinsuha1 May 5, 2025
6a1caee
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 May 5, 2025
93f6789
fix failing CI
hajinsuha1 May 5, 2025
70dcfb1
fix unit tests
hajinsuha1 May 5, 2025
1a3fda9
Merge branch 'feature/extensibility-v2' into implement-dynamic-update…
hajinsuha1 May 8, 2025
c78d0cd
[App Extensibility ⚙️] Remove `extension-` prefix requirement (@W-181…
adamraya May 5, 2025
1bdf645
fix failing CI
hajinsuha1 May 5, 2025
83332ff
fix unit tests
hajinsuha1 May 5, 2025
c0b0803
Merge branch 'implement-dynamic-update-routes' of https://github.com/…
hajinsuha1 May 8, 2025
07598e4
add comment for W-18474745 todo
hajinsuha1 May 8, 2025
75c2a0c
Bump version to 0.1.0-extensibility-preview.5 and update dependencies…
hajinsuha1 May 8, 2025
1d524d1
TEST CHANGES
hajinsuha1 May 8, 2025
98a5011
Revert this commit to TEST CHANGES
hajinsuha1 May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions packages/extension-seo-url-mapping/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright (c) 2021, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

module.exports = {
extends: [require.resolve('@salesforce/pwa-kit-dev/configs/eslint')]
}
1 change: 1 addition & 0 deletions packages/extension-seo-url-mapping/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dev/
5 changes: 5 additions & 0 deletions packages/extension-seo-url-mapping/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
coverage
dist
generator-assets
docs
vendor
7 changes: 7 additions & 0 deletions packages/extension-seo-url-mapping/.prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
printWidth: 100
singleQuote: true
semi: false
bracketSpacing: false
tabWidth: 4
arrowParens: 'always'
trailingComma: 'none'
108 changes: 108 additions & 0 deletions packages/extension-seo-url-mapping/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
:loudspeaker: Hey there, Salesforce Commerce Cloud community!

We’re excited to hear your thoughts on your developer experience with PWA Kit and the Composable Storefront generally! Your feedback is incredibly valuable in helping us guide our roadmap and improve our offering.

:clipboard: Take our quick survey here: [Survey](https://forms.gle/bUZNxQ3QKUcrjhV18)

Feel free to share this survey link with your colleagues, partners, or anyone who has experience with PWA Kit. Your input will help us shape the future of our development tools.

Thank you for being a part of our community and for your continuous support! :raised_hands:

# Description

This is a sample PWA-Kit Application Extension. The purpose of this application extensions is to show how
the Application Extensions API can be used to enhance your PWA-Kit base project.

# Folder Structure

This directory contains the PWA Kit Application Extension base files and structure. It includes the following files:
```
├── src
│ ├── setup-server.ts
│ └── setup-client.ts
└── dev
```

1. `src/setup-server.ts`: The server-side setup function for the extension.
2. `src/setup-client.ts`: The client-side setup function for the extension.
3. `dev/`: PWA Kit App TypeScript template project used for developing the generated PWA Kit App Extension.

# Peer Dependencies

PWA-Kit Application Extensions are NPM packages at their most simplest form, and as such you can define
what peer dependencies are required when using it. Because this sample application extension provides
UI via a new "Sample" page, it requires that the below dependencies are installed at a minimum.

Depending on what features your application extensions provides it's recommended you include any third-party
packages as peer dependencies so that your base application doesn't end up having multiple versions of a
given package.

"react": "^18.2.0",
"react-dom": "^18.2.0"

# Configuration

This section is optional and will depend on your application extensions implementation. If you have features
that are configurable, then list those configurations here so that the PWA-Kit project implementor can configure
the extension as they like.

```
{
path: '/sample-page'
}
```

# Installation

```
> npm install @salesforce/extension-starter<br/>
> Downloading npm package... <br/>
> Installing extension... <br/>
> Finished. <br/>
> Congratulations! The Sample extension was successfully installed! Please visit https://www.npmjs.com/package/@salesforce/extension-starter for more information on how to use this extension.
```

# State Management

By default all extensions are enhanced with state management using the `withApplicationExtensionStore` higher-order component. Under the hood
the state is provided using [Zustand](https://www.npmjs.com/package/zustand) as a global store for the entire PWA-Kit application.
Each Application Extension inserts a "slice" into this global store following the
[slicing pattern](https://github.com/pmndrs/zustand/blob/37e1e3f193a5e5dec6fbd0f07514aec59a187e01/docs/guides/slices-pattern.md).
This allows you to have data separation from one extension to the other, but also allows you to access state and associated actions of other extensions when needed.

You can access the state of other extensions via the global store. Below is an example of why you might want to access state and actions from another extensions. In the following snippet we use the global store to access actions from the store locator. You can then use these actions as you please.

This is how you would do something like this.

```
// /base-project/app/components/my-component.jsx
import {useApplicationExtensionsStore} from '@salesforce/pwa-kit-extension-sdk/react'

export MyComponent = () => {
// Zustand V5 requires stable selector outputs. E.g. Do NOT return a new reference in your selectors return value. This will
// cause infinite re-renders.
const defaultState = {}

// Grab the slice of the extension state for "extension-a"
const {toggleMapsModal} = useApplicationExtensionsStore(
(state) =>
state.state['@salesforce/extension-store-locator'] || defaultState
)

return (
<div>
<button onClick={() => toggleMapsModal()}/>
</div>
)
}
```

# Advanced Usage

As an application extension developer you are responsible for documenting how your extension works including basic usage, its configuration, and advanced customization via overrides. Use this section to explain how your extension can use overrides to accomplish this. Make should to include what files are overridable as well as their expected inputs and outputs.

## Overridable Files

```
/src/path/to/overridable/files.ts
```
89 changes: 89 additions & 0 deletions packages/extension-seo-url-mapping/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Extension Configuration 🧩

In most cases it's beneficial to make your application extension configurable. This will allow your extension to meet the needs of different PWA-Kit developers whom have varying requirements. This can be as simple as configuring the url path to the page your extension adds, to more complex scenarios like configuring layouts to those same pages.


## `Sample` vs `Default` Configurations

This folder is home to two configuration files, `default.json` and `sample.json`. Both of which have their type define in the `src/types/config` file. But these files are used differently. Below is a summary of how each file is used.

### `default.json`

This configuration is used during the project generation as well as the extensions loading phase when running your PWA-Kit application.

During your PWA-Kit project generation, you can select which extensions are configured for your app. This ultimately leads to your applications configuration being setup with the extensions selected during the project questionnaire phase. For example, if you were to choose to use `@salesforce/extension-chakra-storefront` in your PWA-Kit app, then you might see something along the lines of this in your app config, where `<user_defined_configuration>` is initially set to the contents of the `default.json` file:

```
app: {
extensions: [
['@salesforce/extension-chakra-storefront', <user_defined_configuration>]
]
}
```

Additionally, during the PWA-Kit application execution the default configuration is merged with the user define configuration to ensure that all configuration key have a value. This means that you do not have to worry about scattering default values in your extensions code, whether it's in a React component or the setup files.

It's worth noting that if your configuration file is expected to have values supplied by the PWA-Kit application developer, you can use placeholder values that will prompt the developer to replace them with real world values. Below is an example default config file with a placeholder:

```
{
"enabled": true,
"activeDataEnabled": false,
"categoryNav": {
"defaultNavSsrDepth": 1,
"defaultRootCategory": "root"
},
"commerceAPI": {
"proxyPath": "/mobify/proxy/api",
"parameters": {
"clientId": "<CLIENT_ID>",
"organizationId": "<ORGANIZATION_ID>",
"shortCode": "<SHORT_CODE>",
"siteId": "<SITE_ID>"
}
},
...
}
```

### `sample.json`

This configuration is similar in many ways to the one above, with the primary difference being that you cannot use placeholder values in it. The configuration is expected to have all its properties defined with valid values.

This configuration file is used internally by the PWA-Kit create-app application whenever a project is generated using a preset. This allows us to create E2E tests on our CI environment where we know that a project generated can be run without further modification to the configuration file.

We also recommend that you reference this configuration file from your extensions root README so that developers know what a valid configuration looks like.

## How to use your extension configuration?

Your extensions configuration can be used in different ways depending on the context in which you want to use it. Your configuration will primarily be used in two places, your React components and your extension setup files.

### Setup Files

The exported extension classes in `setup-app.ts` and `setup-server.ts` are extended from the `ApplicationExtension` class. This class provide a method called `getConfig` which returns the configuration your extension was instantiated with. you can use this method to grab the configuration and use it however you want.

Please refer to the `src/setup-app.ts` file to see a sample of how it's being used in the `extendRoutes` implementation.

### React Components

Every application extension generated will have a convenience hook scaffolded for you located at `src/hooks/use-extension-config`. You can use this hook in any pages, components, or other hooks that you add to your extension. Below is an example component that uses this hook:

```
// src/components/sample-component.tsx
import React from 'react'
import {useExtensionConfig} from '../hooks/use-extension-config'

export const Sample = (): JSX.Element => {
const {path} = useExtensionConfig()

return (
<span>{path}<span/>
)
}

export default Sample
```

### Other Contexts

If you plan on using the extension configuration in other contexts such as utility files, we recommend that you use dependency injection whenever possible. Passing in the configuration to these utilities will not only be a simple solution, but it will also make testing these utilities easier if you choose to do that.
4 changes: 4 additions & 0 deletions packages/extension-seo-url-mapping/config/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"enabled": true,
"resourceTypeToComponentMap": {}
}
3 changes: 3 additions & 0 deletions packages/extension-seo-url-mapping/extension-meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"id": "@salesforce/extension-seo-url-mapping"
}
Loading
Loading