algolia / instantsearch

⚡️ Libraries for building performant and instant search and recommend experiences with Algolia. Compatible with JavaScript, TypeScript, React and Vue.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/
MIT License
3.71k stars 520 forks source link

Routers.history appears to be missing from the NPM package #4895

Closed jack-pallot closed 3 years ago

jack-pallot commented 3 years ago

🐛 Bug description

When accessing instantsearch.routers.history on my instantsearch instance, I get an undefined error, as if it doesn't exist on the module.

_instantsearch2.default.routers is undefined

However, if I copy the same version of instantsearch.js from a CDN (https://cdn.jsdelivr.net/npm/instantsearch.js@4) and do:

import instantsearch from './instantsearch.js'

Then I can access routers.history just fine.

Is it missing in some way from the NPM package? Or, is there an alternative way to import it?

🔍 Bug reproduction

https://codesandbox.io/s/patient-surf-cej8u?file=/src/app.js

Haroenv commented 3 years ago
import { history } from 'instantsearch.js/es/lib/routers';

https://codesandbox.io/s/happy-mayer-7gb3h?file=/src/app.js:222-281

this is how the history router is imported in es module. Sorry that the umd version doesn't give a warning to use the correct import

jack-pallot commented 3 years ago

Thanks, that works perfectly!