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 9, 2023
1 parent 3ee8b57 commit 3b3e3cc
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 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;
let foundTsconfigMap = new Map<string | undefined, TsConfigResult | null>();
let fileMatcherMap = new Map<string | undefined, FileMatcher>();

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

if (!('tsconfigRaw' in transformOptions)) {
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) {
fileMatcher = createFilesMatcher(foundTsconfig);
}
Expand Down

0 comments on commit 3b3e3cc

Please sign in to comment.