diff --git a/client/jest.config.cjs b/client/jest.config.cjs index c017263847..c405109d1d 100644 --- a/client/jest.config.cjs +++ b/client/jest.config.cjs @@ -36,13 +36,14 @@ module.exports = { restoreMocks: true, testResultsProcessor: 'jest-junit', coverageReporters: ['text', 'cobertura', 'lcov'], + resolver: '/jest.resolver.cjs', transform: { '\\.[jt]sx?$': 'babel-jest', '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'jest-file-loader', }, transformIgnorePatterns: [ - '/node_modules/(?!(@zattoo/use-double-click|@dicebear|@react-dnd|react-dnd.*|dnd-core|filenamify|filename-reserved-regex|heic-to|lowlight|highlight\\.js|fault|react-markdown|unified|bail|trough|devlop|is-.*|parse-entities|stringify-entities|character-.*|trim-lines|style-to-object|inline-style-parser|html-url-attributes|escape-string-regexp|longest-streak|zwitch|ccount|markdown-table|comma-separated-tokens|space-separated-tokens|web-namespaces|property-information|remark-.*|rehype-.*|recma-.*|hast.*|mdast-.*|unist-.*|vfile.*|micromark.*|estree-util-.*|decode-named-character-reference)/)/', + '/node_modules/(?!(@ariakit/react-components|@ariakit/react-utils|@ariakit/react-store|@ariakit/components|@ariakit/store|@ariakit/utils|@zattoo/use-double-click|@dicebear|@react-dnd|react-dnd.*|dnd-core|filenamify|filename-reserved-regex|heic-to|lowlight|highlight\\.js|fault|react-markdown|unified|bail|trough|devlop|is-.*|parse-entities|stringify-entities|character-.*|trim-lines|style-to-object|inline-style-parser|html-url-attributes|escape-string-regexp|longest-streak|zwitch|ccount|markdown-table|comma-separated-tokens|space-separated-tokens|web-namespaces|property-information|remark-.*|rehype-.*|recma-.*|hast.*|mdast-.*|unist-.*|vfile.*|micromark.*|estree-util-.*|decode-named-character-reference)/)/', ], setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect', '/test/setupTests.js'], clearMocks: true, diff --git a/client/jest.resolver.cjs b/client/jest.resolver.cjs new file mode 100644 index 0000000000..562b94887b --- /dev/null +++ b/client/jest.resolver.cjs @@ -0,0 +1,17 @@ +/** + * The modern @ariakit/* split packages (react-components and its peers) are ESM-only and + * declare only an `import` export condition, which jest's CJS resolver can't match. Resolve + * those with the `import` condition; babel (see transformIgnorePatterns) transpiles them to CJS. + */ +const ESM_ONLY_ARIAKIT = + /^@ariakit\/(react-components|react-utils|react-store|components|store|utils)(\/|$)/; + +module.exports = (request, options) => { + if (ESM_ONLY_ARIAKIT.test(request)) { + return options.defaultResolver(request, { + ...options, + conditions: [...(options.conditions ?? []), 'import'], + }); + } + return options.defaultResolver(request, options); +}; diff --git a/client/package.json b/client/package.json index 5128591cbc..8ab7766a4d 100644 --- a/client/package.json +++ b/client/package.json @@ -30,7 +30,7 @@ "homepage": "https://librechat.ai", "dependencies": { "@ariakit/react": "^0.4.29", - "@ariakit/react-core": "^0.4.26", + "@ariakit/react-components": "^0.1.2", "@codesandbox/sandpack-react": "^2.19.10", "@dicebear/collection": "^9.4.1", "@dicebear/core": "^9.4.1", diff --git a/package-lock.json b/package-lock.json index 56be23ef8b..e61012372b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -414,7 +414,7 @@ "license": "ISC", "dependencies": { "@ariakit/react": "^0.4.29", - "@ariakit/react-core": "^0.4.26", + "@ariakit/react-components": "^0.1.2", "@codesandbox/sandpack-react": "^2.19.10", "@dicebear/collection": "^9.4.1", "@dicebear/core": "^9.4.1", @@ -773,13 +773,6 @@ "@ariakit/utils": "0.1.2" } }, - "node_modules/@ariakit/core": { - "version": "0.4.20", - "resolved": "https://registry.npmjs.org/@ariakit/core/-/core-0.4.20.tgz", - "integrity": "sha512-DJbUnui0fM+2ZgiWLOMuFOmlWSJDNV3f6tqghIYRTWEm51TN/LoU6uM8og6/g7Nrwl4Uo5l8AoQT9Kkr/i/uRg==", - "deprecated": "This package has been split into smaller packages. Use @ariakit/components, @ariakit/store, or @ariakit/utils depending on the APIs you need.", - "license": "MIT" - }, "node_modules/@ariakit/react": { "version": "0.4.29", "resolved": "https://registry.npmjs.org/@ariakit/react/-/react-0.4.29.tgz", @@ -815,22 +808,6 @@ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0" } }, - "node_modules/@ariakit/react-core": { - "version": "0.4.26", - "resolved": "https://registry.npmjs.org/@ariakit/react-core/-/react-core-0.4.26.tgz", - "integrity": "sha512-/Peh1KiVpjj79nCJIa6lEdzSTT9P9FZoy+CxByIFKL3YKdlXmDIIhS1E/tAqKbDq4ODVdynnqmrIDxE5wCoZYw==", - "deprecated": "This package has been split into smaller packages. Use @ariakit/react-components or @ariakit/react-utils depending on the APIs you need.", - "license": "MIT", - "dependencies": { - "@ariakit/core": "0.4.20", - "@floating-ui/dom": "^1.0.0", - "use-sync-external-store": "^1.6.0" - }, - "peerDependencies": { - "react": "^17.0.0 || ^18.0.0 || ^19.0.0", - "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0" - } - }, "node_modules/@ariakit/react-store": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/@ariakit/react-store/-/react-store-0.1.2.tgz", @@ -43056,7 +43033,7 @@ }, "peerDependencies": { "@ariakit/react": "^0.4.29", - "@ariakit/react-core": "^0.4.26", + "@ariakit/react-components": "^0.1.2", "@dicebear/collection": "^9.4.1", "@dicebear/core": "^9.4.1", "@headlessui/react": "^2.1.2", diff --git a/packages/client/jest.config.js b/packages/client/jest.config.js index 23822aa097..ce69dcdfdf 100644 --- a/packages/client/jest.config.js +++ b/packages/client/jest.config.js @@ -22,9 +22,12 @@ export default { // React component testing requires jsdom environment testEnvironment: 'jsdom', testEnvironmentOptions: { url: 'http://localhost:3080' }, + resolver: '/jest.resolver.cjs', transform: { '^.+\\.(ts|tsx|js|jsx)$': 'babel-jest', }, - transformIgnorePatterns: ['node_modules/(?!(@tanstack|lucide-react|@dicebear)/)'], + transformIgnorePatterns: [ + 'node_modules/(?!(@tanstack|lucide-react|@dicebear|@ariakit/react-components|@ariakit/react-utils|@ariakit/react-store|@ariakit/components|@ariakit/store|@ariakit/utils)/)', + ], setupFilesAfterEnv: ['/jest.setup.ts'], }; diff --git a/packages/client/jest.resolver.cjs b/packages/client/jest.resolver.cjs new file mode 100644 index 0000000000..562b94887b --- /dev/null +++ b/packages/client/jest.resolver.cjs @@ -0,0 +1,17 @@ +/** + * The modern @ariakit/* split packages (react-components and its peers) are ESM-only and + * declare only an `import` export condition, which jest's CJS resolver can't match. Resolve + * those with the `import` condition; babel (see transformIgnorePatterns) transpiles them to CJS. + */ +const ESM_ONLY_ARIAKIT = + /^@ariakit\/(react-components|react-utils|react-store|components|store|utils)(\/|$)/; + +module.exports = (request, options) => { + if (ESM_ONLY_ARIAKIT.test(request)) { + return options.defaultResolver(request, { + ...options, + conditions: [...(options.conditions ?? []), 'import'], + }); + } + return options.defaultResolver(request, options); +}; diff --git a/packages/client/package.json b/packages/client/package.json index d26093df8f..6c33db4714 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -37,7 +37,7 @@ }, "peerDependencies": { "@ariakit/react": "^0.4.29", - "@ariakit/react-core": "^0.4.26", + "@ariakit/react-components": "^0.1.2", "@dicebear/collection": "^9.4.1", "@dicebear/core": "^9.4.1", "@headlessui/react": "^2.1.2", diff --git a/packages/client/src/components/ControlCombobox.tsx b/packages/client/src/components/ControlCombobox.tsx index d7e9aaa65b..b23d8d622d 100644 --- a/packages/client/src/components/ControlCombobox.tsx +++ b/packages/client/src/components/ControlCombobox.tsx @@ -2,7 +2,7 @@ import { useMemo, useState, useRef, memo, useEffect, MemoExoticComponent } from import * as Ariakit from '@ariakit/react'; import { matchSorter } from 'match-sorter'; import { Search, ChevronDown } from 'lucide-react'; -import { SelectRenderer } from '@ariakit/react-core/select/select-renderer'; +import { SelectRenderer } from '@ariakit/react-components/select/select-renderer'; import type { OptionWithIcon } from '~/common'; import './AnimatePopover.css'; import { JSX } from 'react/jsx-runtime';