Skip to content

Commit b8f6eaa

Browse files
smack0007ahnpnl
authored andcommitted
fix(transformer): allow transforming of .cts/.mts extensions. (#3996)
1 parent 3efa2e2 commit b8f6eaa

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export const LINE_FEED = '\n'
22
export const DECLARATION_TYPE_EXT = '.d.ts'
33
export const JS_JSX_EXTENSIONS = ['.js', '.jsx']
4-
export const TS_TSX_REGEX = /\.m?tsx?$/
5-
export const JS_JSX_REGEX = /\.m?jsx?$/
4+
export const TS_TSX_REGEX = /\.[cm]?tsx?$/
5+
export const JS_JSX_REGEX = /\.[cm]?jsx?$/
66
// `extensionsToTreatAsEsm` will throw error with `.mjs`
77
export const TS_EXT_TO_TREAT_AS_ESM = ['.ts', '.tsx', '.mts']
88
export const JS_EXT_TO_TREAT_AS_ESM = ['.jsx']

src/legacy/ts-jest-transformer.spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ describe('TsJestTransformer', () => {
330330
expect(process.env.TS_JEST).toBe('1')
331331
})
332332

333-
test.each(['foo.ts', 'foo.tsx', 'foo.mts', 'foo.mtsx'])('should process ts/tsx file', (filePath) => {
333+
test.each(['foo.ts', 'foo.tsx', 'foo.cts', 'foo.mts', 'foo.mtsx'])('should process ts/tsx file', (filePath) => {
334334
const fileContent = 'const foo = 1'
335335
const output = 'var foo = 1'
336336
tr.getCacheKey(fileContent, filePath, baseTransformOptions)
@@ -345,7 +345,7 @@ describe('TsJestTransformer', () => {
345345
})
346346
})
347347

348-
test.each(['foo.js', 'foo.jsx', 'foo.mjs', 'foo.mjsx'])(
348+
test.each(['foo.js', 'foo.jsx', 'foo.cjs', 'foo.mjs', 'foo.mjsx'])(
349349
'should process js/jsx file with allowJs true',
350350
(filePath) => {
351351
const fileContent = 'const foo = 1'

0 commit comments

Comments
 (0)