Describe the bug 馃悰
The instantsearch.widgets is not find when opening my browser, but I got zero error when compiling my assets. The error is:
ReferenceError: "instantsearch.widgets" are not available from the ES build.
To import the widgets:
import { searchBox } from 'instantsearch.js/es/widgets'
To Reproduce 馃攳
Steps to reproduce the behavior:
const algoliasearch = require('algoliasearch/lite') andconst instantsearch = require('instantsearch.js').defaultnpm run watchExpected behavior 馃挱
Showing all widgets and searchBox bar, with all my items
Screenshots 馃枼

Environment:
Additional context
I tried with import { searchBox } from 'instantsearch.js/es/widgets' or not, and the problem is still there.
my app.js
require('./bootstrap');
const algoliasearch = require('algoliasearch/lite');
const instantsearch = require('instantsearch.js').default;
import { searchBox } from 'instantsearch.js/es/widgets';
const searchClient = algoliasearch('54CZ551XUU', '89411fb5d2a80b5ee53127d9f67e148c');
const search = instantsearch({
indexName: 'products',
searchClient,
});
search.addWidgets([
instantsearch.widgets.searchBox({
container: '#searchbox',
}),
instantsearch.widgets.hits({
container: '#hits',
})
]);
search.start();
Webpack mix
mix.js('resources/js/app.js', 'public/js')
.sass('resources/sass/app.scss', 'public/css');
package json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.19",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^4.0.7",
"lodash": "^4.17.13",
"popper.js": "^1.12",
"resolve-url-loader": "2.3.1",
"sass": "^1.22.12",
"sass-loader": "7.*",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"algoliasearch": "^3.35.0",
"instantsearch.js": "^3.6.0"
}
}
Thanks for your help ;)
const algoliasearch = require('algoliasearch/lite');
const instantsearch = require('instantsearch.js').default;
import { searchBox, hits } from 'instantsearch.js/es/widgets';
const searchClient = algoliasearch('54CZ551XUU', '89411fb5d2a80b5ee53127d9f67e148c');
const search = instantsearch({
indexName: 'products',
searchClient,
});
search.addWidgets([
searchBox({
container: '#searchbox',
}),
hits({
container: '#hits',
})
]);
search.start();
this should work, the instantsearch.widgets form is for UMD (directly in the browser, without webpack)
const algoliasearch = require('algoliasearch/lite'); const instantsearch = require('instantsearch.js').default; import { searchBox, hits } from 'instantsearch.js/es/widgets'; const searchClient = algoliasearch('54CZ551XUU', '89411fb5d2a80b5ee53127d9f67e148c'); const search = instantsearch({ indexName: 'products', searchClient, }); search.addWidgets([ searchBox({ container: '#searchbox', }), hits({ container: '#hits', }) ]); search.start();this should work, the
instantsearch.widgetsform is for UMD (directly in the browser, without webpack)
Indeed, thanks Haroenv ! But it's very strange, because I've tried the two possibilities given by algolia docs, and now, for no reason, it works. Maybe some cache not reloaded properly I guess. Again, thanks for your help ;)
not sure you saw the difference, but what you wrote was:
instantsearch.widgets.searchBox({
and what it should have been was:
searchBox({
Most helpful comment
this should work, the
instantsearch.widgetsform is for UMD (directly in the browser, without webpack)