Skip to content

Commit 4072754

Browse files
update bundler with dynamic imports
1 parent 5717b40 commit 4072754

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

packages/instantsearch-bundler/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@ http
1717

1818
res.writeHead(200, { 'Content-Type': 'text/javascript' });
1919

20+
// This would be computed based on the configuration
21+
const mappedWidgets = ['searchBox', 'hits', 'pagination'];
22+
2023
const script = `
2124
import algoliasearch from 'algoliasearch/lite';
2225
import instantsearch from 'instantsearch.js';
23-
import { hits } from 'instantsearch.js/es/widgets';
26+
import { ${mappedWidgets.join(', ')} } from 'instantsearch.js/es/widgets';
2427
2528
const searchClient = algoliasearch('${appId}', '${apiKey}');
2629
const search = instantsearch({
@@ -30,11 +33,11 @@ const search = instantsearch({
3033
});
3134
3235
search.addWidgets([
33-
hits({ container: '#hits' }),
34-
])
36+
block({ container: '#block', widgets: [${mappedWidgets.join(', ')}] }),
37+
]);
3538
3639
search.start();
37-
`;
40+
`;
3841

3942
const bundle = buildSync({
4043
bundle: true,

0 commit comments

Comments
 (0)