Skip to content

Commit

Permalink
improve version detection (#4070)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress authored and chrisgervang committed Jan 31, 2020
1 parent 4cbeb1b commit 8a3c41b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions modules/core/src/lib/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ import jsonLoader from '../utils/json-loader';
const version =
typeof __VERSION__ !== 'undefined' ? __VERSION__ : global.DECK_VERSION || 'untranspiled source';

if (global.deck && global.deck.VERSION !== version) {
throw new Error(`deck.gl - multiple versions detected: ${global.deck.VERSION} vs ${version}`);
// Note: a `deck` object not created by deck.gl may exist in the global scope
const existingVersion = global.deck && global.deck.VERSION;

if (existingVersion && existingVersion !== version) {
throw new Error(`deck.gl - multiple versions detected: ${existingVersion} vs ${version}`);
}

if (!global.deck) {
if (!existingVersion) {
// eslint-disable-next-line
if (process.env.NODE_ENV !== 'production') {
log.log(
Expand All @@ -45,13 +48,13 @@ if (!global.deck) {
)();
}

global.deck = global.deck || {
global.deck = Object.assign(global.deck || {}, {
VERSION: version,
version,
log,
// experimental
_registerLoggers: register
};
});

registerLoaders([jsonLoader, ImageLoader]);
}
Expand Down

0 comments on commit 8a3c41b

Please sign in to comment.