Skip to content

Commit

Permalink
fix(dedupe): duplicate_dedupe not work issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alimd committed Aug 31, 2024
1 parent 9d2b657 commit bdf6f52
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/dedupe/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ import type {Dictionary} from '@alwatr/type-helper';

declare global {
// eslint-disable-next-line no-var
var __dedupe__: true;
var __alwatr_dedupe__: true;

// eslint-disable-next-line no-var
var __package_version__: string;
}

if (typeof __dedupe__ !== 'undefined') {
throw new Error('duplicate_dedupe');
const globalScope: typeof globalThis =
(typeof globalThis === 'object' && globalThis) ||
(typeof window === 'object' && window) ||
(typeof global === 'object' && global) ||
self;

if (typeof globalScope.__alwatr_dedupe__ === 'undefined') {
globalScope.__alwatr_dedupe__ = true;
}
else {
console.error('duplicate_alwatr_dedupe', {version: __package_version__});
}

export const definedPackageList: Dictionary<string> = {};
Expand Down

0 comments on commit bdf6f52

Please sign in to comment.