From c15a1bff779787d08ff869d28c2d1a60c824dad6 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Wed, 29 Aug 2018 10:40:09 -0700
Subject: [PATCH] fix circular import issue

---
 src/mol-view/label.ts | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/mol-view/label.ts b/src/mol-view/label.ts
index fe7663346..b2eac2c31 100644
--- a/src/mol-view/label.ts
+++ b/src/mol-view/label.ts
@@ -9,8 +9,9 @@ import { Unit, StructureElement, StructureProperties as Props } from 'mol-model/
 import { Loci } from 'mol-model/loci';
 import { OrderedSet } from 'mol-data/int';
 
-const elementLocA = StructureElement.create()
-const elementLocB = StructureElement.create()
+// for `labelFirst`, don't create right away to avaiod problems with circular dependencies/imports
+let elementLocA: StructureElement
+let elementLocB: StructureElement
 
 function setElementLocation(loc: StructureElement, unit: Unit, index: StructureElement.UnitIndex) {
     loc.unit = unit
@@ -18,6 +19,9 @@ function setElementLocation(loc: StructureElement, unit: Unit, index: StructureE
 }
 
 export function labelFirst(loci: Loci): string {
+    if (!elementLocA) elementLocA = StructureElement.create()
+    if (!elementLocB) elementLocB = StructureElement.create()
+
     switch (loci.kind) {
         case 'element-loci':
             const e = loci.elements[0]
-- 
GitLab