diff --git a/tslib.es6.js b/tslib.es6.js index bd73dce..8083232 100644 --- a/tslib.es6.js +++ b/tslib.es6.js @@ -209,13 +209,20 @@ var __setModuleDefault = Object.create ? (function(o, v) { o["default"] = v; }; -export function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -} +export var __importStar = function (mod) { + var cache = typeof WeakMap === "function" ? new WeakMap() : null; + __importStar = function (mod) { + if (mod === null || (typeof mod !== "object" && typeof mod !== "function")) return { default: mod }; + if (mod.__esModule) return mod; + if (cache && cache.has(mod)) return cache.get(mod); + var result = {}; + for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + if (cache) cache.set(mod, result); + return result; + } + return __importStar(mod); +}; export function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; diff --git a/tslib.js b/tslib.js index 4e2462e..8d350de 100644 --- a/tslib.js +++ b/tslib.js @@ -251,11 +251,18 @@ var __createBinding; }; __importStar = function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; + var cache = typeof WeakMap === "function" ? new WeakMap() : null; + __importStar = function (mod) { + if (mod === null || (typeof mod !== "object" && typeof mod !== "function")) return { default: mod }; + if (mod.__esModule) return mod; + if (cache && cache.has(mod)) return cache.get(mod); + var result = {}; + for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + if (cache) cache.set(mod, result); + return result; + } + return __importStar(mod); }; __importDefault = function (mod) {