Skip to content

Commit

Permalink
interop: Create a separate regex for declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
manuth committed Sep 18, 2022
1 parent f6ea7b7 commit c218be4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/instances.ts
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit c218be4

Please sign in to comment.