Skip to content

Commit 4c726de

Browse files
committed
feat: pd separate bundle
1 parent bf54def commit 4c726de

File tree

22 files changed

+111
-30
lines changed

22 files changed

+111
-30
lines changed

packages/commerce-sdk-react/package.json

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,28 @@
1414
"author": "cc-pwa-kit@salesforce.com",
1515
"main": "dist/index.js",
1616
"types": "dist/index.d.ts",
17+
"sideEffects": false,
18+
"exports": {
19+
".": {
20+
"types": "./dist/index.d.ts",
21+
"import": "./dist/index.js",
22+
"require": "./dist/index.js",
23+
"default": "./dist/index.js"
24+
},
25+
"./page-designer": {
26+
"types": "./dist/page-designer/index.d.ts",
27+
"import": "./dist/page-designer/index.js",
28+
"require": "./dist/page-designer/index.js",
29+
"default": "./dist/page-designer/index.js"
30+
},
31+
"./hooks/*": "./dist/hooks/*",
32+
"./components": "./dist/components/index.js",
33+
"./package.json": "./package.json"
34+
},
1735
"files": [
1836
"CHANGELOG.md",
1937
"LICENSE",
20-
"+(auth|components|hooks|scripts)/**/!(*.test*).{ts,js}",
38+
"+(auth|components|hooks|scripts|page-designer)/**/!(*.test*).{ts,js}",
2139
"*.{js,d.ts}",
2240
"!*.test*.{js,d.ts}",
2341
"!test*.*",
@@ -93,8 +111,5 @@
93111
"react": "^18.2.0",
94112
"react-dom": "^18.2.0"
95113
}
96-
},
97-
"publishConfig": {
98-
"directory": "dist"
99114
}
100115
}

packages/commerce-sdk-react/src/components/ShopperExperience/Component/index.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
* SPDX-License-Identifier: BSD-3-Clause
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
import React, {type ReactElement, memo, Suspense} from 'react'
7+
import React, {
8+
type ReactElement,
9+
memo,
10+
Suspense,
11+
type ComponentType as ReactComponentType
12+
} from 'react'
813
import {registry} from '../registry'
914
import type {ComponentDesignMetadata} from '@salesforce/storefront-next-runtime/design/react'
1015
import type {ComponentType} from '../types'
@@ -15,6 +20,18 @@ export interface ComponentProps {
1520
regionId: string
1621
}
1722

23+
/**
24+
* Props that are passed to dynamic components loaded from the registry.
25+
* This includes design metadata, component data, and region information.
26+
*/
27+
interface DynamicComponentProps extends Record<string, unknown> {
28+
designMetadata: ComponentDesignMetadata
29+
component: ComponentType
30+
regions?: ComponentType['regions']
31+
className?: string
32+
regionId: string
33+
}
34+
1835
export const Component = memo(function Component({
1936
component,
2037
className,
@@ -41,8 +58,11 @@ export const Component = memo(function Component({
4158
id: component.id
4259
}
4360

61+
// Cast DynamicComponent to accept our props since registry returns unknown type
62+
const ComponentToRender = DynamicComponent as ReactComponentType<DynamicComponentProps>
63+
4464
const componentElement = (
45-
<DynamicComponent
65+
<ComponentToRender
4666
{...(component.data ?? {})}
4767
designMetadata={designMetadata}
4868
component={component}
@@ -56,7 +76,7 @@ export const Component = memo(function Component({
5676
const isClient = typeof window !== 'undefined'
5777

5878
if (!isClient) {
59-
return componentElement
79+
return <div>{componentElement}</div>
6080
}
6181

6282
return (

packages/commerce-sdk-react/src/components/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,15 @@
44
* SPDX-License-Identifier: BSD-3-Clause
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
7-
export * from './ShopperExperience'
8-
export * from './StorefrontPreview'
7+
8+
/**
9+
* Components Module
10+
*
11+
* This module exports general-purpose components for commerce applications.
12+
*
13+
* StorefrontPreview: A wrapper component for Business Manager preview integration.
14+
* Import from this path: import { StorefrontPreview } from '@salesforce/commerce-sdk-react/components'
15+
*/
16+
17+
// StorefrontPreview - general preview wrapper component
18+
export {StorefrontPreview} from './StorefrontPreview'

packages/commerce-sdk-react/src/hooks/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
export * from './ShopperBaskets'
88
export * from './ShopperContexts'
99
export * from './ShopperCustomers'
10-
export * from './ShopperExperience'
1110
export * from './ShopperGiftCertificates'
1211
export * from './ShopperLogin'
1312
export * from './ShopperOrders'
@@ -29,4 +28,3 @@ export {default as useConfig} from './useConfig'
2928
export {default as useDNT} from './useDNT'
3029
export {useCustomQuery} from './useQuery'
3130
export {useCustomMutation} from './useMutation'
32-
export {useGlobalAnchorBlock} from './useGlobalAnchorBlock'

packages/commerce-sdk-react/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
import CommerceApiProvider from './provider'
88
export * from './hooks/types'
99
export * from './hooks'
10-
export {registry} from './components'
1110

1211
export {CommerceApiProvider}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2026, Salesforce, Inc.
3+
* All rights reserved.
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+
*/
7+
8+
/**
9+
* Page Designer Integration Module
10+
*
11+
* This module provides components, hooks, and utilities for integrating
12+
* Salesforce Page Designer with React applications. Import from this
13+
* subpath only if you're using Page Designer features.
14+
*
15+
* @example
16+
* ```typescript
17+
* // Import Page Designer features
18+
* import {
19+
* PageDesignerProvider,
20+
* usePageDesignerMode,
21+
* Page,
22+
* usePages
23+
* } from '@salesforce/commerce-sdk-react/page-designer'
24+
* ```
25+
*
26+
* @module page-designer
27+
*/
28+
29+
// Re-export ShopperExperience components (Page Designer rendering)
30+
export * from '../components/ShopperExperience'
31+
32+
// Re-export Page Designer hooks
33+
export * from '../hooks/ShopperExperience'
34+
export {useGlobalAnchorBlock} from '../hooks/useGlobalAnchorBlock'
35+
36+
// Re-export the registry for component registration
37+
export {registry} from '../components/ShopperExperience'

packages/template-retail-react-app/app/components/_app/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import {useUpdateShopperContext} from '@salesforce/retail-react-app/app/hooks/us
6969
// HOCs
7070
import {withCommerceSdkReact} from '@salesforce/retail-react-app/app/components/with-commerce-sdk-react/with-commerce-sdk-react'
7171

72-
import {PageDesignerProvider} from '@salesforce/commerce-sdk-react/components'
72+
import {PageDesignerProvider} from '@salesforce/commerce-sdk-react/page-designer'
7373
import PageDesignerInit from '@salesforce/retail-react-app/app/components/page-designer-init'
7474

7575
// Localization

packages/template-retail-react-app/app/components/page-designer-init/index.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
import React, {useEffect} from 'react'
99
import {Prompt} from 'react-router-dom'
10-
import {usePageDesignerMode} from '@salesforce/commerce-sdk-react/components'
11-
import {useGlobalAnchorBlock} from '@salesforce/commerce-sdk-react'
10+
import {
11+
usePageDesignerMode,
12+
useGlobalAnchorBlock
13+
} from '@salesforce/commerce-sdk-react/page-designer'
1214

1315
/**
1416
* PageDesignerInit - Component that handles Page Designer initialization

packages/template-retail-react-app/app/page-designer/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import {Page, pageType} from '@salesforce/commerce-sdk-react/components'
8+
import {Page, pageType} from '@salesforce/commerce-sdk-react/page-designer'
99

1010
export {Page, pageType}

packages/template-retail-react-app/app/page-designer/layouts/carousel/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
useBreakpoint,
1616
useBreakpointValue
1717
} from '@salesforce/retail-react-app/app/components/shared/ui'
18-
import {Component, regionPropType} from '@salesforce/commerce-sdk-react/components'
18+
import {Component, regionPropType} from '@salesforce/commerce-sdk-react/page-designer'
1919
import {ChevronLeftIcon, ChevronRightIcon} from '@salesforce/retail-react-app/app/components/icons'
2020
import {useEffect} from 'react'
2121
import {useIntl} from 'react-intl'

0 commit comments

Comments
 (0)