Open thiboot opened 1 year ago
the NPM package does contain ECMAScript Modules files
dist/algoliasearch-lite.esm.browser.js
algoliasearch.esm.browser.js
But these files are not referenced in the package.json
. I see different reasons for that :
module
is not supporting multi-entry (as far as I know) and using it wouldn't be standard because the module field is not officialbrowser
field is already in use for umd
. Switching from umd
to esm
files would be a breaking changeTo fix this issue, an exports
field listing all files present in the npm package need to be added to the package.json
(not listing all files, including package.json
itself, would be a breaking change, requiring bumping the major version)
If you need a fix right now, just import the ESM files directly in your app (side effect: Typescript won't be able to type the default export)
exports
has already been discussed here https://github.com/algolia/algoliasearch-client-javascript/issues/1381
An easy fix for the missing TS definition is to create this d.ts
file anywhere in your project
declare module 'algoliasearch/dist/algoliasearch-lite.esm.browser.js' {
export * from 'algoliasearch/dist/algoliasearch-lite';
export { default } from 'algoliasearch/dist/algoliasearch-lite';
}
PS: In order to create a PR, I had a look at the scripts/build.js and rollup.config.js files in this repo but there are simply too many packages generated. It will be safer if a regular maintainer had a look at it
PS2: The name of the d.ts
file can be anything. Only the .d.ts
extension is mandatory
Could you consider using ECMAScript Modules ?
Warning is raised when compiling app with
angular-instantsearch
From angular documentation :