LibreChat/packages/client/jest.resolver.cjs
Danny Avila 5c5ef37e30
⬆️ chore: Migrate off deprecated @ariakit/react-core to @ariakit/react-components (#13940)
* ⬆️ chore: Migrate off deprecated @ariakit/react-core to @ariakit/react-components

@ariakit/react-core and its dependency @ariakit/core are deprecated (split into successor packages) and emit install-time warnings. @ariakit/react already ships the non-deprecated @ariakit/react-components transitively; the only direct use of react-core was the SelectRenderer deep import in ControlCombobox, which is now sourced from @ariakit/react-components/select/select-renderer (identical symbol and subpath). Both deprecated packages drop out of the lockfile and react-components dedupes to the single version @ariakit/react pins.

*  test: Resolve ESM-only @ariakit split packages in jest

@ariakit/react-components and its peers are ESM-only (type: module) and declare only an import export condition, so jest's CJS resolver can't load them when @librechat/client's CJS build requires SelectRenderer. Add a custom jest resolver that resolves these @ariakit/* split packages with the import condition, and extend transformIgnorePatterns so babel transpiles them to CJS. Applied to both the client and packages/client jest configs.
2026-06-24 23:13:57 -04:00

17 lines
676 B
JavaScript

/**
* 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);
};