From f11c3660032a34f3412ab89db6ef58493a31e780 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Thu, 2 Apr 2020 10:36:28 +0200 Subject: [PATCH] chore: move `TransformResult` to types package (#9747) --- CHANGELOG.md | 1 + packages/jest-test-result/package.json | 1 - packages/jest-test-result/src/types.ts | 5 ++--- packages/jest-test-result/tsconfig.json | 1 - packages/jest-transform/src/types.ts | 9 ++------- packages/jest-types/src/Transform.ts | 14 ++++++++++++++ packages/jest-types/src/index.ts | 3 ++- 7 files changed, 21 insertions(+), 13 deletions(-) create mode 100644 packages/jest-types/src/Transform.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index c11c78045dae..323678f18053 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Chore & Maintenance +- `[@jest/test-result]` Remove dependency on `@jest/transform`, which lead to a sprawling dependency tree ([#9747](https://github.com/facebook/jest/pull/9747)) - `[@jest/transform]` Expose type `TransformedSource` ([#9736](https://github.com/facebook/jest/pull/9736)) ### Performance diff --git a/packages/jest-test-result/package.json b/packages/jest-test-result/package.json index cfd9a390f7a2..2299c26ce42a 100644 --- a/packages/jest-test-result/package.json +++ b/packages/jest-test-result/package.json @@ -18,7 +18,6 @@ }, "dependencies": { "@jest/console": "^25.2.3", - "@jest/transform": "^25.2.4", "@jest/types": "^25.2.3", "@types/istanbul-lib-coverage": "^2.0.0", "collect-v8-coverage": "^1.0.0" diff --git a/packages/jest-test-result/src/types.ts b/packages/jest-test-result/src/types.ts index 105631631840..9ed0a99a5439 100644 --- a/packages/jest-test-result/src/types.ts +++ b/packages/jest-test-result/src/types.ts @@ -7,12 +7,11 @@ import type {CoverageMap, CoverageMapData} from 'istanbul-lib-coverage'; import type {ConsoleBuffer} from '@jest/console'; -import type {Config} from '@jest/types'; +import type {Config, TransformTypes} from '@jest/types'; import type {V8Coverage} from 'collect-v8-coverage'; -import type {TransformResult} from '@jest/transform'; export type V8CoverageResult = Array<{ - codeTransformResult: TransformResult | undefined; + codeTransformResult: TransformTypes.TransformResult | undefined; result: V8Coverage[number]; }>; diff --git a/packages/jest-test-result/tsconfig.json b/packages/jest-test-result/tsconfig.json index c8ba8adff346..4a3022904a19 100644 --- a/packages/jest-test-result/tsconfig.json +++ b/packages/jest-test-result/tsconfig.json @@ -6,7 +6,6 @@ }, "references": [ {"path": "../jest-console"}, - {"path": "../jest-transform"}, {"path": "../jest-types"} ] } diff --git a/packages/jest-transform/src/types.ts b/packages/jest-transform/src/types.ts index 9cf2716dbfee..ff280e883afb 100644 --- a/packages/jest-transform/src/types.ts +++ b/packages/jest-transform/src/types.ts @@ -6,7 +6,7 @@ */ import type {RawSourceMap} from 'source-map'; -import type {Config} from '@jest/types'; +import type {Config, TransformTypes} from '@jest/types'; export type ShouldInstrumentOptions = Pick< Config.GlobalConfig, @@ -36,12 +36,7 @@ export type TransformedSource = | {code: string; map?: FixedRawSourceMap | string | null} | string; -export type TransformResult = { - code: string; - originalCode: string; - mapCoverage: boolean; - sourceMapPath: string | null; -}; +export type TransformResult = TransformTypes.TransformResult; export type TransformOptions = { instrument: boolean; diff --git a/packages/jest-types/src/Transform.ts b/packages/jest-types/src/Transform.ts new file mode 100644 index 000000000000..9c59e7b34489 --- /dev/null +++ b/packages/jest-types/src/Transform.ts @@ -0,0 +1,14 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +// this is here to make it possible to avoid huge dependency trees just for types +export type TransformResult = { + code: string; + originalCode: string; + mapCoverage: boolean; + sourceMapPath: string | null; +}; diff --git a/packages/jest-types/src/index.ts b/packages/jest-types/src/index.ts index 36e2c40bff90..7e8989407731 100644 --- a/packages/jest-types/src/index.ts +++ b/packages/jest-types/src/index.ts @@ -8,5 +8,6 @@ import type * as Circus from './Circus'; import type * as Config from './Config'; import type * as Global from './Global'; +import type * as TransformTypes from './Transform'; -export type {Circus, Config, Global}; +export type {Circus, Config, Global, TransformTypes};