25 lines
1022 B
JavaScript
25 lines
1022 B
JavaScript
// A packages cache that makes sure that we don't inject the same packageName twice in the same bundle -
|
|
// this cache is local to the module closure inside this bundle
|
|
var packagesCache = {};
|
|
// Cache access to window to avoid IE11 memory leak.
|
|
var _win = undefined;
|
|
try {
|
|
_win = window;
|
|
}
|
|
catch (e) {
|
|
/* no-op */
|
|
}
|
|
export function setVersion(packageName, packageVersion) {
|
|
if (typeof _win !== 'undefined') {
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
var packages = (_win.__packages__ = _win.__packages__ || {});
|
|
// We allow either the global packages or local packages caches to invalidate so testing can
|
|
// just clear the global to set this state
|
|
if (!packages[packageName] || !packagesCache[packageName]) {
|
|
packagesCache[packageName] = packageVersion;
|
|
var versions = (packages[packageName] = packages[packageName] || []);
|
|
versions.push(packageVersion);
|
|
}
|
|
}
|
|
}
|
|
//# sourceMappingURL=setVersion.js.map
|