Skip to content

Commit f316352

Browse files
authored
refactor(devs-infra): shorten import paths (#3084)
1 parent bacd6af commit f316352

16 files changed

+33
-28
lines changed

e2e/__tests__/presets.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1+
import path from 'path'
2+
3+
import execa from 'execa'
4+
15
import { json as runWithJson } from '../run-jest'
6+
import { tsJestBundle } from '../utils'
27

38
const DIR_NAME = 'presets'
49

10+
beforeAll(() => {
11+
execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], {
12+
cwd: path.join(__dirname, '..', DIR_NAME),
13+
})
14+
})
15+
516
test(`successfully runs the tests inside ${DIR_NAME}`, () => {
617
const { json } = runWithJson(DIR_NAME)
718

e2e/presets/__tests__/ts-jest-presets.spec.ts renamed to e2e/presets/__tests__/presets.spec.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from '../../../dist/constants'
2-
import * as presets from '../../../presets'
1+
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from 'ts-jest'
2+
import presets from 'ts-jest/presets'
33

4-
const defaultPreset = require('../../../jest-preset')
4+
const defaultPreset = require('ts-jest/jest-preset')
55

66
test('presets', () => {
77
expect(defaultPreset).toEqual({
88
transform: {
99
'^.+\\.tsx?$': 'ts-jest',
1010
},
1111
})
12-
1312
expect(presets.defaultsESM).toEqual({
1413
extensionsToTreatAsEsm: [...TS_EXT_TO_TREAT_AS_ESM],
1514
transform: {

src/__helpers__/fakers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { resolve } from 'path'
33
import type { Config } from '@jest/types'
44
import type { Logger } from 'bs-logger'
55

6-
import { TsCompiler } from '../compiler/ts-compiler'
7-
import { ConfigSet } from '../config/config-set'
6+
import { TsCompiler } from '../compiler'
7+
import { ConfigSet } from '../config'
88
import type { StringMap, TsJestGlobalOptions } from '../types'
99
import type { ImportReasons } from '../utils/messages'
1010

src/__helpers__/mocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { testing } from 'bs-logger'
22

3-
import { rootLogger } from '../utils/logger'
3+
import { rootLogger } from '../utils'
44

55
export const logTargetMock = (): testing.LogTargetMock => (rootLogger as testing.LoggerMock).target
66

src/cli/cli.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as _fs from 'fs'
22
import { normalize, resolve } from 'path'
33

44
import { logTargetMock, mockObject, mockWriteStream } from '../__helpers__/mocks'
5-
import { mocked } from '../utils/testing'
5+
import { mocked } from '../utils'
66

77
import { processArgv } from '.'
88

src/cli/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LogContexts, Logger } from 'bs-logger'
22
import type { Arguments } from 'yargs'
33
import yargsParser from 'yargs-parser'
44

5-
import { rootLogger } from '../utils/logger'
5+
import { rootLogger } from '../utils'
66

77
const VALID_COMMANDS = ['help', 'config:migrate', 'config:init']
88

src/compiler/compiler-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { stringify } from '../utils/json'
1+
import { stringify } from '../utils'
22

33
/**
44
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.

src/compiler/ts-compiler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type {
2222
Diagnostic,
2323
} from 'typescript'
2424

25-
import type { ConfigSet } from '../config/config-set'
25+
import type { ConfigSet } from '../config'
2626
import { LINE_FEED, TS_TSX_REGEX } from '../constants'
2727
import type {
2828
DepGraphInfo,
@@ -32,7 +32,7 @@ import type {
3232
TsJestCompileOptions,
3333
TTypeScript,
3434
} from '../types'
35-
import { rootLogger } from '../utils/logger'
35+
import { rootLogger } from '../utils'
3636
import { Errors, interpolate } from '../utils/messages'
3737

3838
import { updateOutput } from './compiler-utils'

src/compiler/ts-jest-compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ConfigSet } from '../config/config-set'
1+
import type { ConfigSet } from '../config'
22
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../types'
33

44
import { TsCompiler } from './ts-compiler'

src/config/config-set.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import ts from 'typescript'
88
import { createConfigSet } from '../__helpers__/fakers'
99
import { logTargetMock } from '../__helpers__/mocks'
1010
import type { AstTransformerDesc, TsJestGlobalOptions } from '../types'
11+
import { stringify, mocked } from '../utils'
1112
import * as _backports from '../utils/backports'
1213
import { getPackageVersion } from '../utils/get-package-version'
13-
import { stringify } from '../utils/json'
1414
import { normalizeSlashes } from '../utils/normalize-slashes'
1515
import { sha1 } from '../utils/sha1'
16-
import { mocked } from '../utils/testing'
1716

1817
import { ConfigSet, MY_DIGEST } from './config-set'
1918

src/config/config-set.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ import type {
3131
TsJestGlobalOptions,
3232
TTypeScript,
3333
} from '../types'
34+
import { stringify, rootLogger } from '../utils'
3435
import { backportJestConfig } from '../utils/backports'
3536
import { importer } from '../utils/importer'
36-
import { stringify } from '../utils/json'
37-
import { rootLogger } from '../utils/logger'
3837
import { Errors, ImportReasons, interpolate } from '../utils/messages'
3938
import { normalizeSlashes } from '../utils/normalize-slashes'
4039
import { sha1 } from '../utils/sha1'

src/config/paths-to-module-name-mapper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Config } from '@jest/types'
22
import { LogContexts } from 'bs-logger'
33
import type { CompilerOptions } from 'typescript'
44

5-
import { rootLogger } from '../utils/logger'
5+
import { rootLogger } from '../utils'
66
import { Errors, interpolate } from '../utils/messages'
77

88
type TsPathMapping = Exclude<CompilerOptions['paths'], undefined>

src/presets/create-jest-preset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Config } from '@jest/types'
22

33
import type { TsJestPresets } from '../types'
4-
import { rootLogger } from '../utils/logger'
4+
import { rootLogger } from '../utils'
55

66
const logger = rootLogger.child({ namespace: 'jest-preset' })
77

src/transformers/path-mapping.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path'
33
import ts from 'typescript'
44

55
import { createConfigSet, makeCompiler } from '../__helpers__/fakers'
6-
import { TsCompiler } from '../compiler/ts-compiler'
6+
import { TsCompiler } from '../compiler'
77
import { normalizeSlashes } from '../utils/normalize-slashes'
88

99
import { factory as pathMapping, name, version } from './path-mapping'

src/ts-jest-transformer.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import { removeSync, writeFileSync } from 'fs-extra'
66

77
import { createConfigSet } from './__helpers__/fakers'
88
import { logTargetMock } from './__helpers__/mocks'
9-
import { SOURCE_MAPPING_PREFIX } from './compiler/compiler-utils'
10-
import { TsJestCompiler } from './compiler/ts-jest-compiler'
9+
import { SOURCE_MAPPING_PREFIX, TsJestCompiler } from './compiler'
1110
import { CACHE_KEY_EL_SEPARATOR, TsJestTransformer } from './ts-jest-transformer'
1211
import type { DepGraphInfo } from './types'
13-
import { stringify } from './utils/json'
12+
import { stringify } from './utils'
1413
import { sha1 } from './utils/sha1'
1514

1615
const logTarget = logTargetMock()

src/ts-jest-transformer.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import type { SyncTransformer, TransformedSource } from '@jest/transform'
55
import type { Config } from '@jest/types'
66
import type { Logger } from 'bs-logger'
77

8-
import { TsJestCompiler } from './compiler/ts-jest-compiler'
9-
import { ConfigSet } from './config/config-set'
8+
import { TsJestCompiler } from './compiler'
9+
import { ConfigSet } from './config'
1010
import { DECLARATION_TYPE_EXT, JS_JSX_REGEX, TS_TSX_REGEX } from './constants'
1111
import type { CompilerInstance, DepGraphInfo, ProjectConfigTsJest, TransformOptionsTsJest } from './types'
12-
import { parse, stringify } from './utils/json'
13-
import { JsonableValue } from './utils/jsonable-value'
14-
import { rootLogger } from './utils/logger'
12+
import { parse, stringify, JsonableValue, rootLogger } from './utils'
1513
import { Errors, interpolate } from './utils/messages'
1614
import { sha1 } from './utils/sha1'
1715
import { VersionCheckers } from './utils/version-checkers'

0 commit comments

Comments
 (0)