algolia / vue-instantsearch

👀 Algolia components for building search UIs with Vue.js
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue
MIT License
854 stars 157 forks source link

"Failed to resolve module specifier" when using esmodules #1165

Closed tylermmorton closed 1 year ago

tylermmorton commented 1 year ago

Bug 🐞

What is the current behavior?

While attempting to use vue-instantsearch without a build step through native esmodules vue-instantsearch fails to load and an error is printed to the console:

Uncaught TypeError: Failed to resolve module specifier "instantsearch.js/es/connectors/index.js". Relative references must start with either "/", "./", or "../".

Make a sandbox with the current behavior

https://jsfiddle.net/erdw124a/

What is the expected behavior?

vue-instantsearch is usable through esmodules and import-maps

Does this happen only in specific situations?

I believe this is only a problem when using native es modules. I have not tried vue-instantsearch with a build step yet. I'd really like to avoid this alternative if possible.

What is the proposed solution?

What is the version you are using?

"algoliasearch": "https://unpkg.com/algoliasearch@4.14.2/dist/algoliasearch-lite.esm.browser.js",
"instantsearch.js": "https://cdn.jsdelivr.net/npm/instantsearch.js@4.49.1/dist/instantsearch.production.min.js",
"vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js",
"vue-instantsearch": "https://cdn.jsdelivr.net/npm/vue-instantsearch@4.6.0/vue3/es/index.js"
Haroenv commented 1 year ago

This hasn't been supported yet by us, but I believe you can use import maps or a cdn that rewrites the imports (I believe snowpack does this)