fix(umd): remove chat components from react umd bundle#6714
Conversation
| const createConfiguration = ({ name, minify = false } = {}) => ({ | ||
| input: 'src/index.ts', | ||
| input: 'src/index.umd.ts', | ||
| external: ['react', 'ai'], |
There was a problem hiding this comment.
I left 'ai' as external here, otherwise we would have to update all hook imports in widgets, which is not worth it. Marking 'ai' as external has no impact on the UMD bundle.
There was a problem hiding this comment.
What change would be needed if ai is not marked as external? and how come this doesn't throw on usage without ai?
There was a problem hiding this comment.
You would need to update all hook imports in all widgets, ie:
-import { useBreadcrumb } from 'react-instantsearch-core';
+import { useBreadcrumb } from 'react-instantsearch-core/es/index.umd';Rollup fails otherwise because, even if it will tree shake the imports, it will still traverse and read them. Because useChat is available from 'react-instantsearch-core', it will reach zod which will fail the process.
It doesn't fail on usage because no export of ai is actually referenced in the bundle.
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
| export const SearchIndexToolType = undefined; | ||
| export const createDefaultTools = () => {}; |
There was a problem hiding this comment.
These should probably move to ui-components or js/lib/chat in the future.
Summary
This PR updates react-instantsearch to not export
useChatandChaton the UMD bundle, since we're not bundling ai. There are also changes to the UMD test file in order to add more in-depths assertions and additionally cover react-instantsearch-core + vue-instantsearch (vue3).FX-3530