Skip to content

Commit a31bbc5

Browse files
committed
MAGE-998 Implement mock bundle
1 parent 686f8f4 commit a31bbc5

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

view/frontend/web/js/instantsearch.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,37 @@
11
define([
22
'jquery',
3-
'algoliaBundle',
3+
4+
// Algolia core UI libs
45
'algoliaSearchLib',
56
'algoliaInstantSearchLib',
7+
8+
// Algolia integration dependencies
69
'algoliaTemplateEngine',
10+
11+
// Magento libs
712
'Magento_Catalog/js/price-utils',
13+
14+
// DEPRECATED: Legacy bundle libs to be removed in a future release
15+
'algoliaHoganLib',
16+
'algoliaAutocompleteLib',
17+
18+
// TODO: Refactor legacy global object dependencies
819
'algoliaCommon',
920
'algoliaInsights',
1021
'algoliaHooks',
11-
], function ($, algoliaBundle, algoliasearch, instantsearch, templateEngine, priceUtils) {
22+
], function ($, algoliasearch, instantsearch, templateEngine, priceUtils, Hogan, autocomplete) {
23+
24+
// @deprecated algoliaBundle is going away!
25+
// Howver if you've used it in any of your customizations it can be mocked - documentation to come on how to do this...
26+
const mockAlgoliaBundle = {
27+
$,
28+
Hogan,
29+
algoliasearch,
30+
// algoliasearchHelper ???
31+
autocomplete
32+
};
33+
console.log("Mock bundle:", mockAlgoliaBundle);
34+
1235
$(async function ($) {
1336
const templateProcessor = await templateEngine.getSelectedEngineAdapter();
1437

@@ -172,7 +195,7 @@ define([
172195
instantsearchOptions = algolia.triggerHooks(
173196
'beforeInstantsearchInit',
174197
instantsearchOptions,
175-
algoliaBundle
198+
mockAlgoliaBundle
176199
);
177200

178201
var search = instantsearch(instantsearchOptions);
@@ -852,7 +875,7 @@ define([
852875
allWidgetConfiguration = algolia.triggerHooks(
853876
'beforeWidgetInitialization',
854877
allWidgetConfiguration,
855-
algoliaBundle
878+
mockAlgoliaBundle
856879
);
857880

858881
$.each(allWidgetConfiguration, function (widgetType, widgetConfig) {
@@ -892,13 +915,13 @@ define([
892915
search = algolia.triggerHooks(
893916
'beforeInstantsearchStart',
894917
search,
895-
algoliaBundle
918+
mockAlgoliaBundle
896919
);
897920
search.start();
898921
search = algolia.triggerHooks(
899922
'afterInstantsearchStart',
900923
search,
901-
algoliaBundle
924+
mockAlgoliaBundle
902925
);
903926

904927
isStarted = true;

0 commit comments

Comments
 (0)