From c218be48e2db044b2b8917dfb373ff0c9712d545 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sun, 18 Sep 2022 11:27:19 +0000 Subject: [PATCH] interop: Create a separate regex for declarations --- src/constants.ts | 1 + src/instances.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index f7a9db273..06f5fda4b 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -10,6 +10,7 @@ export const LineFeedCode = 1; export const extensionRegex = /\.[^.]+$/; export const tsxRegex = /\.tsx$/i; export const tsTsxRegex = /\.([cm]?ts|tsx)$/i; +export const declarationRegex = /\.d\.([cm]?ts|tsx)$/i; export const dtsDtsxOrDtsDtsxMapRegex = /\.d\.([cm]?ts|tsx)(\.map)?$/i; export const dtsTsTsxRegex = /(\.d)?\.([cm]?ts|tsx)$/i; export const dtsTsTsxJsJsxRegex = /((\.d)?\.([cm]?[tj]s|[tj]sx))$/i; diff --git a/src/instances.ts b/src/instances.ts index 711a029d8..afc52376d 100644 --- a/src/instances.ts +++ b/src/instances.ts @@ -7,7 +7,12 @@ import * as webpack from 'webpack'; import { makeAfterCompile } from './after-compile'; import { getCompiler, getCompilerOptions } from './compilerSetup'; import { getConfigFile, getConfigParseResult } from './config'; -import { dtsDtsxOrDtsDtsxMapRegex, EOL, tsTsxRegex } from './constants'; +import { + declarationRegex, + dtsDtsxOrDtsDtsxMapRegex, + EOL, + tsTsxRegex, +} from './constants'; import { getTSInstanceFromCache, setTSInstanceInCache } from './instance-cache'; import { FilePathKey, LoaderOptions, TSFiles, TSInstance } from './interfaces'; import * as logger from './logger'; @@ -682,7 +687,7 @@ export function getInputFileNameFromOutput( instance: TSInstance, filePath: string ): string | undefined { - if (filePath.match(tsTsxRegex) && !/\.d\.([cm]?ts|tsx)$/.test(filePath)) { + if (filePath.match(tsTsxRegex) && !declarationRegex.test(filePath)) { return undefined; } if (instance.solutionBuilderHost) {