You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In some circumstances the MeiliSearch packages was not importable.
It threw an error when trying to use it.
When does the problem occurs
When trying to import MeiliSearch in an es6 environments that imports the main package present in the package.json and not the module package, it imports the cjs version and not the esm.
your issue is due to the mismatch between how commonjs export stuff module.exports = something and how ES6 export stuff export default something.
To fix this it you just have to enable esModuleInterop in your tsconfig compile option, also enable allowSyntheticDefaultImports for typesystem compatibility
esModuleInterop was set as true in the tsconfig.json of the MeiliSearch packages but it was overide by the default typescript configuration of the rollup-typescript plugin.
I case someone is having this problem and already has "esModuleInterop" in their "tsconfig.json". My solutions was to change the import thar inits meili from import MeiliSearch from "meilisearch"; to this import { MeiliSearch } from "meilisearch";
My problem occurred after updating using firebase functions with node 12. And going from meili: 0.16.1 to 0.18.1.
Hope it helps. ;)
Hey @Flucadetena. We made a breaking change in the 0.18.1 where import { MeiliSearch } from "meilisearch is now the way to import meilisearch. Thanks a lot for answering this issue as it might help users come by here.
Here is the complete change log: https://github.com/meilisearch/meilisearch-js/releases/tag/v0.18.0
In some circumstances the MeiliSearch packages was not importable.
It threw an error when trying to use it.
When does the problem occurs
When trying to import MeiliSearch in an
es6
environments that imports themain
package present in the package.json and not themodule
package, it imports thecjs
version and not theesm
.This throws an error.
Exemple
Using NestJS :
What causes the problem
As explained in this comment.
esModuleInterop
was set as true in thetsconfig.json
of the MeiliSearch packages but it was overide by the default typescript configuration of the rollup-typescript plugin.As explained in this issue: ezolenko/rollup-plugin-typescript2#226
Which in our case was not the
incude
option but theesModuleInterop
option.How to fix it
Overide the rollup default configuration using the
tsconfigOverride
in the plugin's option.How to prevent it
We should make basic end-to-end tests on different environments (ESM, Node, Typescript, UMD,..) if the plugin is importable and usable.
The text was updated successfully, but these errors were encountered: