Skip to content

Commit

Permalink
Fixes #325 ensures correct caching in parallel webpack builds
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Jul 14, 2023
1 parent 3ee8b57 commit 654dd6b
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
} from 'get-tsconfig';
import type { LoaderOptions } from './types.js';

let foundTsconfig: TsConfigResult | null;
let fileMatcher: FileMatcher;
const foundTsconfigMap = new Map<string | undefined, TsConfigResult | null>();
const fileMatcherMap = new Map<string | undefined, FileMatcher>();

async function ESBuildLoader(
this: webpack.loader.LoaderContext,
Expand Down Expand Up @@ -49,18 +49,27 @@ async function ESBuildLoader(
};

if (!('tsconfigRaw' in transformOptions)) {
console.log(tsconfig);
let fileMatcher = fileMatcherMap.get(tsconfig);
if (!fileMatcher) {
const tsconfigPath = tsconfig && path.resolve(tsconfig);
foundTsconfig = (
tsconfigPath
? {
config: parseTsconfig(tsconfigPath),
path: tsconfigPath,
}
: getTsconfig()
);
let foundTsconfig = foundTsconfigMap.get(tsconfig);
if (!foundTsconfig) {
foundTsconfig = (
tsconfigPath
? {
config: parseTsconfig(tsconfigPath),
path: tsconfigPath,
}
: getTsconfig()
);
}
if (foundTsconfig) {
foundTsconfigMap.set(tsconfig, foundTsconfig);
fileMatcher = createFilesMatcher(foundTsconfig);
if (fileMatcher) {
fileMatcherMap.set(tsconfig, fileMatcher);
}
}
}

Expand Down

0 comments on commit 654dd6b

Please sign in to comment.