diff --git a/tslib.es6.js b/tslib.es6.js index 422345d..6905dff 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -185,11 +185,23 @@ export function __makeTemplateObject(cooked, raw) { return cooked; }; +var __getImportStarCache = function () { + if (typeof WeakMap !== "function") return null; + + var cache = new WeakMap(); + __getImportStarCache = function () { return cache; } + return cache; +}; + export function __importStar(mod) { if (mod && mod.__esModule) return mod; + if (mod === null || (typeof mod !== "object" && typeof mod !== "function")) return { default: mod } + var cache = __getImportStarCache(); + if (cache && cache.has(mod)) return cache.get(mod); var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; + if (cache) cache.set(mod, result); return result; } diff --git a/tslib.js b/tslib.js index f736d07..93136ab 100644 --- a/tslib.js +++ b/tslib.js @@ -222,11 +222,23 @@ var __importDefault; return cooked; }; + var __getImportStarCache = function () { + if (typeof WeakMap !== "function") return null; + + var cache = new WeakMap(); + __getImportStarCache = function () { return cache; } + return cache; + }; + __importStar = function (mod) { if (mod && mod.__esModule) return mod; + if (mod === null || (typeof mod !== "object" && typeof mod !== "function")) return { "default": mod } + var cache = __getImportStarCache(); + if (cache && cache.has(mod)) return cache.get(mod); var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; + if (cache) cache.set(mod, result); return result; };