Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
interop: Create a separate regex for declarations
  • Loading branch information
neurolag committed Sep 18, 2022
commit c218be48e2db044b2b8917dfb373ff0c9712d545
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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