Skip to content

Commit

Permalink
Merge pull request #502 from sedlakr/bugfix/499
Browse files Browse the repository at this point in the history
Dependency walker map checking supports new TS ModeAwareCache
  • Loading branch information
erikbarke authored Dec 25, 2021
2 parents 4effc68 + 8c0664d commit f4cdc43
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/karma-typescript/src/bundler/dependency-walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ export class DependencyWalker {

let dependencyCount = 0;
const ambientModuleNames = this.collectAmbientModules(queue);
// check resolved modules map for TS >= 4.5.1
const isTS45Map = function (map: any) {
return typeof map.get === "function" &&
typeof map.set === "function" &&
typeof map.delete === "function" &&
typeof map.has === "function" &&
typeof map.forEach === "function" &&
typeof map.size === "function";
}

queue.forEach((queued) => {

Expand All @@ -39,7 +48,7 @@ export class DependencyWalker {

if (resolvedModules && !queued.emitOutput.isDeclarationFile) {

if (lodash.isMap(resolvedModules)) { // Typescript 2.2+
if (isTS45Map(resolvedModules) || lodash.isMap(resolvedModules)) { // Typescript 2.2+
resolvedModules.forEach((resolvedModule: any, moduleName: string) => {
this.addBundleItem(queued, resolvedModule, moduleName, ambientModuleNames);
});
Expand Down

0 comments on commit f4cdc43

Please sign in to comment.