Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make TsJestTransformer become legacy #3451

Merged
merged 1 commit into from Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion e2e/ast-transformers/hoist-jest/jest-isolated.config.js
Expand Up @@ -13,6 +13,6 @@ module.exports = {
react$: '<rootDir>/node_modules/react',
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/ast-transformers/hoist-jest/package.json
Expand Up @@ -16,7 +16,7 @@
"react$": "<rootDir>/node_modules/react"
},
"transform": {
"^.+\\.[tj]sx?$": "<rootDir>/../../../dist/index.js"
"^.+\\.[tj]sx?$": "<rootDir>/../../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/ast-transformers/transformer-in-ts/package.json
Expand Up @@ -11,7 +11,7 @@
}
},
"transform": {
"^.+\\.[tj]sx?$": "<rootDir>/../../../dist/index.js"
"^.+\\.[tj]sx?$": "<rootDir>/../../../legacy.js"
}
}
}
Expand Up @@ -16,6 +16,6 @@ module.exports = {
},
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/ast-transformers/transformer-options/package.json
Expand Up @@ -20,7 +20,7 @@
}
},
"transform": {
"^.+\\.[tj]sx?$": "<rootDir>/../../../dist/index.js"
"^.+\\.[tj]sx?$": "<rootDir>/../../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/const-enum/jest-isolated.config.js
Expand Up @@ -6,6 +6,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/const-enum/package.json
@@ -1,7 +1,7 @@
{
"jest": {
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/coverage-report/jest-isolated.config.js
Expand Up @@ -7,6 +7,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/coverage-report/package.json
Expand Up @@ -7,7 +7,7 @@
"!**/coverage/**"
],
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/custom-compiler/ttypescript/package.json
Expand Up @@ -10,7 +10,7 @@
}
},
"transform": {
"^.+.tsx?$": "<rootDir>/../../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/diagnostics/jest-disabled.config.js
Expand Up @@ -6,6 +6,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/diagnostics/jest-exclude.config.js
Expand Up @@ -8,6 +8,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/diagnostics/jest-ignored-code.config.js
Expand Up @@ -8,6 +8,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/diagnostics/jest-isolated.config.js
Expand Up @@ -6,6 +6,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/diagnostics/jest-warn.config.js
Expand Up @@ -8,6 +8,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/diagnostics/package.json
@@ -1,7 +1,7 @@
{
"jest": {
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/enum/jest-isolated.config.js
Expand Up @@ -6,6 +6,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/enum/package.json
@@ -1,7 +1,7 @@
{
"jest": {
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
4 changes: 2 additions & 2 deletions e2e/extend-ts-jest/foo-transformer.js
@@ -1,8 +1,8 @@
const tsJestTransformer = require('../../dist/ts-jest-transformer')
const tsJestTransformer = require('../../dist/legacy/ts-jest-transformer')

class FooTransformer extends tsJestTransformer.TsJestTransformer {
async processAsync(sourceText, sourcePath, transformOptions) {
return new Promise((resolve) => resolve(this.process(sourceText, sourcePath, transformOptions)))
return Promise.resolve(this.process(sourceText, sourcePath, transformOptions))
}
}
module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion e2e/native-esm-js/isolated/package.json
Expand Up @@ -13,7 +13,7 @@
"@jest/globals": "<rootDir>/../../../node_modules/@jest/globals"
},
"transform": {
"^.+.tsx?$": "<rootDir>/../../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/native-esm-js/non-isolated/package.json
Expand Up @@ -15,7 +15,7 @@
"@jest/globals": "<rootDir>/../../../node_modules/@jest/globals"
},
"transform": {
"^.+.tsx?$": "<rootDir>/../../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/native-esm-ts/jest-isolated.config.js
Expand Up @@ -8,6 +8,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/native-esm-ts/package.json
Expand Up @@ -7,7 +7,7 @@
}
},
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/presets/package.json
Expand Up @@ -9,7 +9,7 @@
}
},
"transform": {
"^.+.[tj]sx?$": "<rootDir>/../../dist/index.js"
"^.+.[tj]sx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/source-map/disabled/jest-isolated.config.js
Expand Up @@ -11,6 +11,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/source-map/disabled/jest.config.js
Expand Up @@ -10,6 +10,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/source-map/enabled/jest-isolated.config.js
Expand Up @@ -8,6 +8,6 @@ module.exports = {
},
},
transform: {
'^.+.tsx?$': '<rootDir>/../../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/source-map/enabled/jest.config.js
Expand Up @@ -3,6 +3,6 @@ module.exports = {
displayName: 'sourcemap-enabled',
roots: ['<rootDir>', '<rootDir>/../__tests__'],
transform: {
'^.+.tsx?$': '<rootDir>/../../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/test-utils/package.json
@@ -1,7 +1,7 @@
{
"jest": {
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion e2e/transform-js/babel-cjs-file/jest.config.js
Expand Up @@ -13,6 +13,6 @@ module.exports = {
'babel-jest': '<rootDir>/../../../node_modules/babel-jest',
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/transform-js/babel-enabled/jest.config.js
Expand Up @@ -13,6 +13,6 @@ module.exports = {
'babel-jest': '<rootDir>/../../../node_modules/babel-jest',
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/transform-js/babel-js-file/jest.config.js
Expand Up @@ -13,6 +13,6 @@ module.exports = {
'babel-jest': '<rootDir>/../../../node_modules/babel-jest',
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/transform-js/no-type-check/jest.config.js
Expand Up @@ -9,6 +9,6 @@ module.exports = {
},
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/transform-js/type-check/jest.config.js
Expand Up @@ -8,6 +8,6 @@ module.exports = {
},
},
transform: {
'^.+.[tj]sx?$': '<rootDir>/../../../dist/index.js',
'^.+.[tj]sx?$': '<rootDir>/../../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/transform-tsx/jest-isolated.config.js
Expand Up @@ -7,6 +7,6 @@ module.exports = {
},
testEnvironment: 'jsdom',
transform: {
'^.+.tsx?$': '<rootDir>/../../dist/index.js',
'^.+.tsx?$': '<rootDir>/../../legacy.js',
},
}
2 changes: 1 addition & 1 deletion e2e/transform-tsx/package.json
Expand Up @@ -7,7 +7,7 @@
"jest": {
"testEnvironment": "jsdom",
"transform": {
"^.+.tsx?$": "<rootDir>/../../dist/index.js"
"^.+.tsx?$": "<rootDir>/../../legacy.js"
}
}
}
2 changes: 1 addition & 1 deletion jest.config.js
Expand Up @@ -12,6 +12,6 @@ module.exports = {
snapshotSerializers: [require.resolve('jest-snapshot-serializer-raw')],
testPathIgnorePatterns: ['src/__mocks__/*', '/node_modules/', '/examples/', '/e2e/.*/__tests__', '\\.snap$'],
transform: {
'^.+.tsx?$': '<rootDir>/dist/index.js',
'^.+.tsx?$': '<rootDir>/legacy.js',
},
}
1 change: 1 addition & 0 deletions legacy.js
@@ -0,0 +1 @@
module.exports = require('./dist/legacy')
2 changes: 1 addition & 1 deletion src/index.spec.ts
@@ -1,4 +1,4 @@
import { TsJestTransformer } from './ts-jest-transformer'
import { TsJestTransformer } from './legacy/ts-jest-transformer'

import tsJest from '.'

Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
@@ -1,14 +1,16 @@
import { TsJestTransformer } from './ts-jest-transformer'
import { TsJestTransformer } from './legacy'

export * from './legacy'
export * from './constants'
export * from './compiler'
export * from './config'
export * from './presets/create-jest-preset'
export * from './utils'
export * from './raw-compiler-options'
export * from './ts-jest-transformer'
export * from './types'

export default {
createTransformer: (): TsJestTransformer => new TsJestTransformer(),
createTransformer() {
return new TsJestTransformer(true)
},
}
7 changes: 7 additions & 0 deletions src/legacy/index.ts
@@ -0,0 +1,7 @@
import { TsJestTransformer } from './ts-jest-transformer'

export * from './ts-jest-transformer'

export default {
createTransformer: (): TsJestTransformer => new TsJestTransformer(),
}
Expand Up @@ -4,14 +4,15 @@ import path from 'path'
import { LogLevels } from 'bs-logger'
import { removeSync, writeFileSync } from 'fs-extra'

import { createConfigSet } from './__helpers__/fakers'
import { logTargetMock } from './__helpers__/mocks'
import { TsJestCompiler } from './compiler'
import { createConfigSet } from '../__helpers__/fakers'
import { logTargetMock } from '../__helpers__/mocks'
import { TsJestCompiler } from '../compiler'
import type { DepGraphInfo } from '../types'
import { stringify } from '../utils'
import { importer } from '../utils/importer'
import { sha1 } from '../utils/sha1'

import { CACHE_KEY_EL_SEPARATOR, TsJestTransformer } from './ts-jest-transformer'
import type { DepGraphInfo } from './types'
import { stringify } from './utils'
import { importer } from './utils/importer'
import { sha1 } from './utils/sha1'

const SOURCE_MAPPING_PREFIX = 'sourceMappingURL='

Expand Down