Skip to content

Commit

Permalink
feat: mark TsJestTransformer as legacy (#3451)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Apr 24, 2022
1 parent 724d2b0 commit b090179
Show file tree
Hide file tree
Showing 45 changed files with 80 additions and 59 deletions.
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

0 comments on commit b090179

Please sign in to comment.