From 0f2fe306762d8549bd29737becd4aed14a650427 Mon Sep 17 00:00:00 2001 From: Ahn <27772165+ahnpnl@users.noreply.github.com> Date: Mon, 25 Apr 2022 23:46:29 +0200 Subject: [PATCH] feat: mark `TsCompiler` and `TsJestCompiler` as legacy (#3457) BREAKING CHANGE - Any imports `ts-jest/dist/compiler/ts-compiler` should change to `ts-jest/dist/legacy/compiler/ts-compiler` - Any imports `ts-jest/dist/compiler/ts-jest-compiler` should change to `ts-jest/dist/legacy/compiler/ts-jest-compiler` --- src/__helpers__/fakers.ts | 2 +- src/index.ts | 2 +- .../compiler/__snapshots__/ts-compiler.spec.ts.snap | 0 src/{ => legacy}/compiler/index.ts | 0 src/{ => legacy}/compiler/ts-compiler.spec.ts | 6 +++--- src/{ => legacy}/compiler/ts-compiler.ts | 10 +++++----- src/{ => legacy}/compiler/ts-jest-compiler.spec.ts | 2 +- src/{ => legacy}/compiler/ts-jest-compiler.ts | 4 ++-- src/legacy/ts-jest-transformer.spec.ts | 2 +- src/legacy/ts-jest-transformer.ts | 2 +- src/transformers/path-mapping.spec.ts | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) rename src/{ => legacy}/compiler/__snapshots__/ts-compiler.spec.ts.snap (100%) rename src/{ => legacy}/compiler/index.ts (100%) rename src/{ => legacy}/compiler/ts-compiler.spec.ts (99%) rename src/{ => legacy}/compiler/ts-compiler.ts (98%) rename src/{ => legacy}/compiler/ts-jest-compiler.spec.ts (95%) rename src/{ => legacy}/compiler/ts-jest-compiler.ts (91%) diff --git a/src/__helpers__/fakers.ts b/src/__helpers__/fakers.ts index 936ee00d3f..5566b94948 100644 --- a/src/__helpers__/fakers.ts +++ b/src/__helpers__/fakers.ts @@ -3,7 +3,7 @@ import { resolve } from 'path' import type { Config } from '@jest/types' import type { Logger } from 'bs-logger' -import { TsCompiler } from '../compiler' +import { TsCompiler } from '../legacy/compiler' import { ConfigSet } from '../legacy/config/config-set' import type { StringMap, TsJestGlobalOptions } from '../types' import type { ImportReasons } from '../utils/messages' diff --git a/src/index.ts b/src/index.ts index 5260b69652..01267d7450 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,7 +2,7 @@ import { TsJestTransformer } from './legacy' export * from './legacy' export * from './constants' -export * from './compiler' +export * from './legacy/compiler' export * from './config' export * from './presets/create-jest-preset' export * from './utils' diff --git a/src/compiler/__snapshots__/ts-compiler.spec.ts.snap b/src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap similarity index 100% rename from src/compiler/__snapshots__/ts-compiler.spec.ts.snap rename to src/legacy/compiler/__snapshots__/ts-compiler.spec.ts.snap diff --git a/src/compiler/index.ts b/src/legacy/compiler/index.ts similarity index 100% rename from src/compiler/index.ts rename to src/legacy/compiler/index.ts diff --git a/src/compiler/ts-compiler.spec.ts b/src/legacy/compiler/ts-compiler.spec.ts similarity index 99% rename from src/compiler/ts-compiler.spec.ts rename to src/legacy/compiler/ts-compiler.spec.ts index 2e46b60e6d..8e833a26b5 100644 --- a/src/compiler/ts-compiler.spec.ts +++ b/src/legacy/compiler/ts-compiler.spec.ts @@ -3,9 +3,9 @@ import { basename, join, normalize } from 'path' import { CompilerOptions, DiagnosticCategory, EmitOutput, TranspileOutput } from 'typescript' -import { createConfigSet, makeCompiler } from '../__helpers__/fakers' -import type { DepGraphInfo } from '../types' -import { Errors, interpolate } from '../utils/messages' +import { createConfigSet, makeCompiler } from '../../__helpers__/fakers' +import type { DepGraphInfo } from '../../types' +import { Errors, interpolate } from '../../utils/messages' import { TsCompiler } from './ts-compiler' diff --git a/src/compiler/ts-compiler.ts b/src/legacy/compiler/ts-compiler.ts similarity index 98% rename from src/compiler/ts-compiler.ts rename to src/legacy/compiler/ts-compiler.ts index 73c63b05ef..98aa69c6ca 100644 --- a/src/compiler/ts-compiler.ts +++ b/src/legacy/compiler/ts-compiler.ts @@ -23,8 +23,7 @@ import type { TranspileOutput, } from 'typescript' -import { LINE_FEED, TS_TSX_REGEX } from '../constants' -import type { ConfigSet } from '../legacy/config/config-set' +import { LINE_FEED, TS_TSX_REGEX } from '../../constants' import type { DepGraphInfo, StringMap, @@ -32,9 +31,10 @@ import type { TsJestAstTransformer, TsJestCompileOptions, TTypeScript, -} from '../types' -import { rootLogger } from '../utils' -import { Errors, interpolate } from '../utils/messages' +} from '../../types' +import { rootLogger } from '../../utils' +import { Errors, interpolate } from '../../utils/messages' +import type { ConfigSet } from '../config/config-set' export class TsCompiler implements TsCompilerInstance { protected readonly _logger: Logger diff --git a/src/compiler/ts-jest-compiler.spec.ts b/src/legacy/compiler/ts-jest-compiler.spec.ts similarity index 95% rename from src/compiler/ts-jest-compiler.spec.ts rename to src/legacy/compiler/ts-jest-compiler.spec.ts index d37eb012ff..7f83e59be2 100644 --- a/src/compiler/ts-jest-compiler.spec.ts +++ b/src/legacy/compiler/ts-jest-compiler.spec.ts @@ -1,4 +1,4 @@ -import { createConfigSet } from '../__helpers__/fakers' +import { createConfigSet } from '../../__helpers__/fakers' import { TsCompiler } from './ts-compiler' import { TsJestCompiler } from './ts-jest-compiler' diff --git a/src/compiler/ts-jest-compiler.ts b/src/legacy/compiler/ts-jest-compiler.ts similarity index 91% rename from src/compiler/ts-jest-compiler.ts rename to src/legacy/compiler/ts-jest-compiler.ts index c7fe28e385..3252e9ec2f 100644 --- a/src/compiler/ts-jest-compiler.ts +++ b/src/legacy/compiler/ts-jest-compiler.ts @@ -1,7 +1,7 @@ import type { TransformedSource } from '@jest/transform' -import type { ConfigSet } from '../legacy/config/config-set' -import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../types' +import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../../types' +import type { ConfigSet } from '../config/config-set' import { TsCompiler } from './ts-compiler' diff --git a/src/legacy/ts-jest-transformer.spec.ts b/src/legacy/ts-jest-transformer.spec.ts index 847b218f13..6c0470c897 100644 --- a/src/legacy/ts-jest-transformer.spec.ts +++ b/src/legacy/ts-jest-transformer.spec.ts @@ -6,12 +6,12 @@ import { removeSync, writeFileSync } from 'fs-extra' 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 { TsJestCompiler } from './compiler' import { CACHE_KEY_EL_SEPARATOR, TsJestTransformer } from './ts-jest-transformer' const SOURCE_MAPPING_PREFIX = 'sourceMappingURL=' diff --git a/src/legacy/ts-jest-transformer.ts b/src/legacy/ts-jest-transformer.ts index e5da0e4ba0..eb0aaeb95e 100644 --- a/src/legacy/ts-jest-transformer.ts +++ b/src/legacy/ts-jest-transformer.ts @@ -4,7 +4,6 @@ import path from 'path' import type { SyncTransformer, TransformedSource } from '@jest/transform' import type { Logger } from 'bs-logger' -import { TsJestCompiler } from '../compiler' import { DECLARATION_TYPE_EXT, JS_JSX_REGEX, TS_TSX_REGEX } from '../constants' import type { CompilerInstance, DepGraphInfo, ProjectConfigTsJest, TransformOptionsTsJest } from '../types' import { parse, stringify, JsonableValue, rootLogger } from '../utils' @@ -13,6 +12,7 @@ import { Deprecations, Errors, interpolate } from '../utils/messages' import { sha1 } from '../utils/sha1' import { VersionCheckers } from '../utils/version-checkers' +import { TsJestCompiler } from './compiler' import { ConfigSet } from './config/config-set' interface CachedConfigSet { diff --git a/src/transformers/path-mapping.spec.ts b/src/transformers/path-mapping.spec.ts index ff64767cb2..e4a4104bb6 100644 --- a/src/transformers/path-mapping.spec.ts +++ b/src/transformers/path-mapping.spec.ts @@ -3,7 +3,7 @@ import path from 'path' import ts from 'typescript' import { createConfigSet, makeCompiler } from '../__helpers__/fakers' -import { TsCompiler } from '../compiler' +import { TsCompiler } from '../legacy/compiler' import { normalizeSlashes } from '../utils/normalize-slashes' import { factory as pathMapping, name, version } from './path-mapping'