-
-
Notifications
You must be signed in to change notification settings - Fork 647
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve #1843 - avoid running dexie in double instances.
1. Export ony one require-based module and a MJS wrapper for it. Skip dual export. 2. Detect double instances and let 2nd instance return same instance as was already imported.
- Loading branch information
1 parent
7c13770
commit fc572aa
Showing
3 changed files
with
15 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
// Making the module version consumable via require - to prohibit | ||
// multiple occurrancies of the same module in the same app | ||
// (dual package hazard, https://nodejs.org/api/packages.html#dual-package-hazard) | ||
import Dexie from "./dist/dexie.min.js"; | ||
import _Dexie from "./dist/dexie.min.js"; | ||
const DexieSymbol = Symbol.for("Dexie"); | ||
const Dexie = globalThis[DexieSymbol] || (globalThis[DexieSymbol] = _Dexie); | ||
if (_Dexie.semVer !== Dexie.semVer) { | ||
throw new Error(`Two different versions of Dexie loaded in the same app: ${_Dexie.semVer} and ${Dexie.semVer}`); | ||
} | ||
const { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp } = Dexie; | ||
export { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp, Dexie }; | ||
export default Dexie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
// Making the module version consumable via require - to prohibit | ||
// multiple occurrancies of the same module in the same app | ||
// (dual package hazard, https://nodejs.org/api/packages.html#dual-package-hazard) | ||
import Dexie from "./dist/dexie.js"; | ||
import _Dexie from "./dist/dexie.js"; | ||
const DexieSymbol = Symbol.for("Dexie"); | ||
const Dexie = globalThis[DexieSymbol] || (globalThis[DexieSymbol] = _Dexie); | ||
if (_Dexie.semVer !== Dexie.semVer) { | ||
throw new Error(`Two different versions of Dexie loaded in the same app: ${_Dexie.semVer} and ${Dexie.semVer}`); | ||
} | ||
const { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp } = Dexie; | ||
export { liveQuery, mergeRanges, rangesOverlap, RangeSet, cmp, Dexie }; | ||
export default Dexie; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters