shipperhq / module-shipper

Base ShipperHQ Repo
Open Software License 3.0
21 stars 20 forks source link

ShipperHQ Calendar: Circular RequireJS Dependency #134

Closed pykettk closed 7 months ago

pykettk commented 8 months ago

Description

The ShipperHQ_Calendar/js/model/config.js module defines a dependency on the ShipperHQ_Calendar/js/model/timeslot.js module, which in turn defines a dependency on the ShipperHQ_Calendar/js/model/config.js module - which is obviously circular. While this does not cause an issue in and of itself, trying to create a mixin for these modules fails silently and simply causes the checkout to load infinitely.

As the ShipperHQ_Calendar/js/model/config.js module is not actually used by the ShipperHQ_Calendar/js/model/timeslot.js module, the fix is relatively straightforward:

diff --git a/src/view/frontend/web/js/model/timeslot.js b/src/view/frontend/web/js/model/timeslot.js
index 4217600a..c79ce4c1 100644
--- a/src/view/frontend/web/js/model/timeslot.js
+++ b/src/view/frontend/web/js/model/timeslot.js
@@ -27,8 +27,8 @@
  * @author ShipperHQ Team sales@shipperhq.com
  */
 define(
-    ['ko', 'ShipperHQ_Calendar/js/model/config'],
-    function (ko, calendarConfig) {
+    ['ko'],
+    function (ko) {
         'use strict';
         var timeslots = ko.observableArray([]);
         //SHQ16-2162 moved declaration

The file paths for the modules in question are:

Notes

I've opened this issue here because the shipperhq/module-calendar package is not open source.

wsajosh commented 8 months ago

Hey @pykettk

Thanks for raising this and providing a suggested solution! It's appreciated. Let me get this raised internally for review and if approved, we'll release a new update and let you know here once it's out.

wsajosh commented 7 months ago

@pykettk I've just released 22.9.2 which removes this dependency. Thanks for raising this, much appreciated.