fix(recommend): only export default function #1514
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #1512 I exported Recommend methods in addition to the existing default function export, to allow
algoliasearch
to import them in CJS.This causes an issue as now there are multiple exports, which means
recommend()
cannot be accessed directly and is instead available fromrequire('@algolia/recommend').default
.To prevent this, the Recommend methods are now augmenting the default function export.
Note
The existing version of api-extractor does not correctly resolve type imports, resulting in
import('../xyz').Type
statements with relative paths that are incorrect. I updated to the fixed version and went through all 22 type declaration files. There are no meaningful changes (in some cases type imports are aliased with a suffix to prevent conflicts, ie:import { Type as Type_2 } from '...'
, but all exports have the appropriate name, and now imports are properly resolved.Tests on the built bundles are also added to catch this in CI.
Fixes #1515