Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 22 additions & 0 deletions .changeset/gentle-badgers-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
"@bigcommerce/catalyst-core": patch
---

Uses regular `dompurify` (DP) instead of `isomorphic-dompurify` (IDP), because IDP requires JSDOM. JSDOM doesn't work in edge-runtime environments even with nodejs compatibility. We only need it on the client anyways for the JSON-LD schema, so it doesn't need the isomorphic aspect of it. This also changes `core/app/[locale]/(default)/product/[slug]/_components/product-review-schema/product-review-schema.tsx` to be a client-component to enable `dompurify to work correctly.

## Migration

1. Remove the old dependency and add the new:
```bash
pnpm rm isomorphic-dompurify
pnpm add dompurify -S
```

2. Change the import in `core/app/[locale]/(default)/product/[slug]/_components/product-review-schema/product-review-schema.tsx`:
```diff
- import DOMPurify from 'isomorphic-dompurify';
+// eslint-disable-next-line import/no-named-as-default
+import DOMPurify from 'dompurify';
```

3. Add the `'use client';` directive to the top of `core/app/[locale]/(default)/product/[slug]/_components/product-review-schema/product-review-schema.tsx`.
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import DOMPurify from 'isomorphic-dompurify';
'use client';

// eslint-disable-next-line import/no-named-as-default
import DOMPurify from 'dompurify';
import { useFormatter } from 'next-intl';
import { Product as ProductSchemaType, WithContext } from 'schema-dts';

Expand Down
2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"embla-carousel-react": "8.5.2",
"gql.tada": "^1.8.10",
"graphql": "^16.11.0",
"isomorphic-dompurify": "^2.25.0",
"dompurify": "^3.3.1",
"jose": "^5.10.0",
"lodash.debounce": "^4.0.8",
"lru-cache": "^11.1.0",
Expand Down
74 changes: 39 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.