@@ -34,7 +34,6 @@ import {
3434import { makeWatchRun } from './watch-run' ;
3535
3636const instancesBySolutionBuilderConfigs = new Map < FilePathKey , TSInstance > ( ) ;
37- const detectWebpack5 = ! ! ( webpack as any ) . sources ;
3837
3938/**
4039 * The loader is executed once for each file seen by webpack. However, we need to keep
@@ -45,7 +44,8 @@ const detectWebpack5 = !!(webpack as any).sources;
4544 */
4645export function getTypeScriptInstance (
4746 loaderOptions : LoaderOptions ,
48- loader : webpack . LoaderContext < LoaderOptions >
47+ loader : webpack . LoaderContext < LoaderOptions > ,
48+ isWebpack5 : boolean
4949) : { instance ?: TSInstance ; error ?: webpack . WebpackError } {
5050 const existing = getTSInstanceFromCache (
5151 loader . _compiler ! ,
@@ -73,6 +73,7 @@ export function getTypeScriptInstance(
7373 return successfulTypeScriptInstance (
7474 loaderOptions ,
7575 loader ,
76+ isWebpack5 ,
7677 log ,
7778 colors ,
7879 compiler . compiler ! ,
@@ -120,6 +121,7 @@ function createFilePathKeyMapper(
120121function successfulTypeScriptInstance (
121122 loaderOptions : LoaderOptions ,
122123 loader : webpack . LoaderContext < LoaderOptions > ,
124+ isWebpack5 : boolean ,
123125 log : logger . Logger ,
124126 colors : chalk . Chalk ,
125127 compiler : typeof typescript ,
@@ -149,7 +151,7 @@ function successfulTypeScriptInstance(
149151
150152 const { configFilePath, configFile } = configFileAndPath ;
151153
152- if ( configFilePath && detectWebpack5 ) {
154+ if ( configFilePath && isWebpack5 ) {
153155 loader . addBuildDependency ( configFilePath ) ;
154156 }
155157
@@ -217,7 +219,7 @@ function successfulTypeScriptInstance(
217219 // quick return for transpiling
218220 // we do need to check for any issues with TS options though
219221 const transpileInstance : TSInstance = {
220- isWebpack5 : detectWebpack5 ,
222+ isWebpack5,
221223 compiler,
222224 compilerOptions,
223225 appendTsTsxSuffixesIfRequired,
@@ -276,7 +278,7 @@ function successfulTypeScriptInstance(
276278 }
277279
278280 const instance : TSInstance = {
279- isWebpack5 : detectWebpack5 ,
281+ isWebpack5,
280282 compiler,
281283 compilerOptions,
282284 appendTsTsxSuffixesIfRequired,
0 commit comments