Skip to content

Commit

Permalink
refactor(devs-infra): shorten import paths (#3084)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Nov 20, 2021
1 parent bacd6af commit f316352
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 28 deletions.
11 changes: 11 additions & 0 deletions e2e/__tests__/presets.test.ts
@@ -1,7 +1,18 @@
import path from 'path'

import execa from 'execa'

import { json as runWithJson } from '../run-jest'
import { tsJestBundle } from '../utils'

const DIR_NAME = 'presets'

beforeAll(() => {
execa.sync('npm', ['install', '--no-package-lock', '--no-shrinkwrap', '--no-save', tsJestBundle], {
cwd: path.join(__dirname, '..', DIR_NAME),
})
})

test(`successfully runs the tests inside ${DIR_NAME}`, () => {
const { json } = runWithJson(DIR_NAME)

Expand Down
@@ -1,15 +1,14 @@
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from '../../../dist/constants'
import * as presets from '../../../presets'
import { JS_EXT_TO_TREAT_AS_ESM, TS_EXT_TO_TREAT_AS_ESM } from 'ts-jest'
import presets from 'ts-jest/presets'

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

test('presets', () => {
expect(defaultPreset).toEqual({
transform: {
'^.+\\.tsx?$': 'ts-jest',
},
})

expect(presets.defaultsESM).toEqual({
extensionsToTreatAsEsm: [...TS_EXT_TO_TREAT_AS_ESM],
transform: {
Expand Down
4 changes: 2 additions & 2 deletions src/__helpers__/fakers.ts
Expand Up @@ -3,8 +3,8 @@ import { resolve } from 'path'
import type { Config } from '@jest/types'
import type { Logger } from 'bs-logger'

import { TsCompiler } from '../compiler/ts-compiler'
import { ConfigSet } from '../config/config-set'
import { TsCompiler } from '../compiler'
import { ConfigSet } from '../config'
import type { StringMap, TsJestGlobalOptions } from '../types'
import type { ImportReasons } from '../utils/messages'

Expand Down
2 changes: 1 addition & 1 deletion src/__helpers__/mocks.ts
@@ -1,6 +1,6 @@
import type { testing } from 'bs-logger'

import { rootLogger } from '../utils/logger'
import { rootLogger } from '../utils'

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

Expand Down
2 changes: 1 addition & 1 deletion src/cli/cli.spec.ts
Expand Up @@ -2,7 +2,7 @@ import * as _fs from 'fs'
import { normalize, resolve } from 'path'

import { logTargetMock, mockObject, mockWriteStream } from '../__helpers__/mocks'
import { mocked } from '../utils/testing'
import { mocked } from '../utils'

import { processArgv } from '.'

Expand Down
2 changes: 1 addition & 1 deletion src/cli/index.ts
Expand Up @@ -2,7 +2,7 @@ import { LogContexts, Logger } from 'bs-logger'
import type { Arguments } from 'yargs'
import yargsParser from 'yargs-parser'

import { rootLogger } from '../utils/logger'
import { rootLogger } from '../utils'

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

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/compiler-utils.ts
@@ -1,4 +1,4 @@
import { stringify } from '../utils/json'
import { stringify } from '../utils'

/**
* Rely on TypeScript compiled output generation which contains this prefix to point to sourcemap location.
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/ts-compiler.ts
Expand Up @@ -22,7 +22,7 @@ import type {
Diagnostic,
} from 'typescript'

import type { ConfigSet } from '../config/config-set'
import type { ConfigSet } from '../config'
import { LINE_FEED, TS_TSX_REGEX } from '../constants'
import type {
DepGraphInfo,
Expand All @@ -32,7 +32,7 @@ import type {
TsJestCompileOptions,
TTypeScript,
} from '../types'
import { rootLogger } from '../utils/logger'
import { rootLogger } from '../utils'
import { Errors, interpolate } from '../utils/messages'

import { updateOutput } from './compiler-utils'
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/ts-jest-compiler.ts
@@ -1,4 +1,4 @@
import type { ConfigSet } from '../config/config-set'
import type { ConfigSet } from '../config'
import type { CompilerInstance, StringMap, TsJestCompileOptions } from '../types'

import { TsCompiler } from './ts-compiler'
Expand Down
3 changes: 1 addition & 2 deletions src/config/config-set.spec.ts
Expand Up @@ -8,12 +8,11 @@ import ts from 'typescript'
import { createConfigSet } from '../__helpers__/fakers'
import { logTargetMock } from '../__helpers__/mocks'
import type { AstTransformerDesc, TsJestGlobalOptions } from '../types'
import { stringify, mocked } from '../utils'
import * as _backports from '../utils/backports'
import { getPackageVersion } from '../utils/get-package-version'
import { stringify } from '../utils/json'
import { normalizeSlashes } from '../utils/normalize-slashes'
import { sha1 } from '../utils/sha1'
import { mocked } from '../utils/testing'

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

Expand Down
3 changes: 1 addition & 2 deletions src/config/config-set.ts
Expand Up @@ -31,10 +31,9 @@ import type {
TsJestGlobalOptions,
TTypeScript,
} from '../types'
import { stringify, rootLogger } from '../utils'
import { backportJestConfig } from '../utils/backports'
import { importer } from '../utils/importer'
import { stringify } from '../utils/json'
import { rootLogger } from '../utils/logger'
import { Errors, ImportReasons, interpolate } from '../utils/messages'
import { normalizeSlashes } from '../utils/normalize-slashes'
import { sha1 } from '../utils/sha1'
Expand Down
2 changes: 1 addition & 1 deletion src/config/paths-to-module-name-mapper.ts
Expand Up @@ -2,7 +2,7 @@ import type { Config } from '@jest/types'
import { LogContexts } from 'bs-logger'
import type { CompilerOptions } from 'typescript'

import { rootLogger } from '../utils/logger'
import { rootLogger } from '../utils'
import { Errors, interpolate } from '../utils/messages'

type TsPathMapping = Exclude<CompilerOptions['paths'], undefined>
Expand Down
2 changes: 1 addition & 1 deletion src/presets/create-jest-preset.ts
@@ -1,7 +1,7 @@
import type { Config } from '@jest/types'

import type { TsJestPresets } from '../types'
import { rootLogger } from '../utils/logger'
import { rootLogger } from '../utils'

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

Expand Down
2 changes: 1 addition & 1 deletion src/transformers/path-mapping.spec.ts
Expand Up @@ -3,7 +3,7 @@ import path from 'path'
import ts from 'typescript'

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

import { factory as pathMapping, name, version } from './path-mapping'
Expand Down
5 changes: 2 additions & 3 deletions src/ts-jest-transformer.spec.ts
Expand Up @@ -6,11 +6,10 @@ import { removeSync, writeFileSync } from 'fs-extra'

import { createConfigSet } from './__helpers__/fakers'
import { logTargetMock } from './__helpers__/mocks'
import { SOURCE_MAPPING_PREFIX } from './compiler/compiler-utils'
import { TsJestCompiler } from './compiler/ts-jest-compiler'
import { SOURCE_MAPPING_PREFIX, TsJestCompiler } from './compiler'
import { CACHE_KEY_EL_SEPARATOR, TsJestTransformer } from './ts-jest-transformer'
import type { DepGraphInfo } from './types'
import { stringify } from './utils/json'
import { stringify } from './utils'
import { sha1 } from './utils/sha1'

const logTarget = logTargetMock()
Expand Down
8 changes: 3 additions & 5 deletions src/ts-jest-transformer.ts
Expand Up @@ -5,13 +5,11 @@ import type { SyncTransformer, TransformedSource } from '@jest/transform'
import type { Config } from '@jest/types'
import type { Logger } from 'bs-logger'

import { TsJestCompiler } from './compiler/ts-jest-compiler'
import { ConfigSet } from './config/config-set'
import { TsJestCompiler } from './compiler'
import { ConfigSet } from './config'
import { DECLARATION_TYPE_EXT, JS_JSX_REGEX, TS_TSX_REGEX } from './constants'
import type { CompilerInstance, DepGraphInfo, ProjectConfigTsJest, TransformOptionsTsJest } from './types'
import { parse, stringify } from './utils/json'
import { JsonableValue } from './utils/jsonable-value'
import { rootLogger } from './utils/logger'
import { parse, stringify, JsonableValue, rootLogger } from './utils'
import { Errors, interpolate } from './utils/messages'
import { sha1 } from './utils/sha1'
import { VersionCheckers } from './utils/version-checkers'
Expand Down

0 comments on commit f316352

Please sign in to comment.