Skip to content
Open
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
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ import '@patternfly/chatbot/dist/css/main.css';

If you are using React 17, ChatBot currently has a dependency on [react-markdown](https://github.com/remarkjs/react-markdown) that relies on React 18 and 19. There is an older version of react-markdown (8.0.7) that supports 17, but it does not have support for 19. You should be able to add `"react"` and `"react-dom"` of the appropriate version to the `overrides` section of your `package.json` file if you need to use ChatBot with 17.

### Tree-shaking

Import each component from its dynamic entry point to keep bundle size minimal:

```tsx
import ChatbotToggle from '@patternfly/chatbot/dist/dynamic/ChatbotToggle';
```

Named imports from the root barrel also tree-shake with modern bundlers that respect the package `sideEffects` field.

`CodeModal`, `PreviewAttachment`, `AttachmentEdit`, and `tracking` are not exported from the root barrel — import them from `dist/dynamic/<Component>` instead. See `packages/module/patternfly-docs/content/extensions/chatbot/tree-shaking.md` for migration details.

To verify tree-shaking in this repo:

```bash
npm run build -w @patternfly/chatbot
npm run analyze:tree-shaking
```

See `packages/tree-shaking-demo/README.md` for full results and best practices.

## Contribution guide

### AI-assisted development guidelines
Expand Down
3 changes: 3 additions & 0 deletions config/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import 'whatwg-fetch';
import 'babel-polyfill';
import '@testing-library/jest-dom';
beforeAll(async () => {
await import('../packages/module/src/MarkdownContent/MarkdownRenderer');
});

global.SVGPathElement = function () {};

Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ module.exports = {
modulePathIgnorePatterns: [
'<rootDir>/packages/*.*/dist/*.*',
'<rootDir>/packages/*.*/public/*.*',
'<rootDir>/packages/*.*/.cache/*.*'
'<rootDir>/packages/*.*/.cache/*.*',
'<rootDir>/packages/tree-shaking-demo/*.*'
],
moduleNameMapper: {
'\\.(css|scss)$': 'identity-obj-proxy',
Expand Down
Loading
Loading