From 4f2bcb861d1f0fb150c05970362e52a38c31f67e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Fri, 11 Jan 2019 14:51:59 +0000 Subject: [PATCH] Migrate back to CommonJS export for jest-runtime (#7608) --- packages/jest-cli/src/__tests__/SearchSource.test.js | 2 +- .../src/__tests__/dependency_resolver.test.js | 2 +- packages/jest-runner/src/runTest.js | 2 +- packages/jest-runtime/src/__mocks__/createRuntime.js | 2 +- packages/jest-runtime/src/cli/index.js | 6 ++++-- packages/jest-runtime/src/index.js | 2 +- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/jest-cli/src/__tests__/SearchSource.test.js b/packages/jest-cli/src/__tests__/SearchSource.test.js index 45b94705c573..53d979ec0d56 100644 --- a/packages/jest-cli/src/__tests__/SearchSource.test.js +++ b/packages/jest-cli/src/__tests__/SearchSource.test.js @@ -31,7 +31,7 @@ describe('SearchSource', () => { let searchSource; beforeEach(() => { - Runtime = require('jest-runtime').default; + Runtime = require('jest-runtime'); SearchSource = require('../SearchSource').default; normalize = require('jest-config').normalize; }); diff --git a/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.js b/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.js index 9105fa5883f4..3725c9bc951f 100644 --- a/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.js +++ b/packages/jest-resolve-dependencies/src/__tests__/dependency_resolver.test.js @@ -23,7 +23,7 @@ const cases = { const filter = path => Object.keys(cases).every(key => cases[key](path)); beforeEach(() => { - Runtime = require('jest-runtime').default; + Runtime = require('jest-runtime'); config = normalize( { rootDir: '.', diff --git a/packages/jest-runner/src/runTest.js b/packages/jest-runner/src/runTest.js index aaa174eefa33..d388d1c427e0 100644 --- a/packages/jest-runner/src/runTest.js +++ b/packages/jest-runner/src/runTest.js @@ -73,7 +73,7 @@ async function runTestInternal( const Runtime = ((config.moduleLoader ? /* $FlowFixMe */ require(config.moduleLoader) - : require('jest-runtime').default): Class); + : require('jest-runtime')): Class); let runtime = undefined; diff --git a/packages/jest-runtime/src/__mocks__/createRuntime.js b/packages/jest-runtime/src/__mocks__/createRuntime.js index c88e036b8edd..ae951f28cbec 100644 --- a/packages/jest-runtime/src/__mocks__/createRuntime.js +++ b/packages/jest-runtime/src/__mocks__/createRuntime.js @@ -9,7 +9,7 @@ import path from 'path'; module.exports = function createRuntime(filename, config) { const NodeEnvironment = require('jest-environment-node'); - const Runtime = require('../').default; + const Runtime = require('../'); const {normalize} = require('jest-config'); diff --git a/packages/jest-runtime/src/cli/index.js b/packages/jest-runtime/src/cli/index.js index 2dcb4ee76a33..601f9aea4d28 100644 --- a/packages/jest-runtime/src/cli/index.js +++ b/packages/jest-runtime/src/cli/index.js @@ -17,8 +17,6 @@ import yargs from 'yargs'; import {Console, setGlobal} from 'jest-util'; import {validateCLIOptions} from 'jest-validate'; import {readConfig, deprecationEntries} from 'jest-config'; -// eslint-disable-next-line import/default -import Runtime from '../'; import * as args from './args'; const VERSION = (require('../../package.json').version: string); @@ -75,6 +73,10 @@ export function run(cliArgv?: Argv, cliInfo?: Array) { automock: false, unmockedModulePathPatterns: null, }); + + // Break circular dependency + const Runtime = require('..'); + Runtime.createContext(config, { maxWorkers: Math.max(os.cpus().length - 1, 1), watchman: globalConfig.watchman, diff --git a/packages/jest-runtime/src/index.js b/packages/jest-runtime/src/index.js index c1c8f10e6cf2..05dc03a7a35b 100644 --- a/packages/jest-runtime/src/index.js +++ b/packages/jest-runtime/src/index.js @@ -1017,4 +1017,4 @@ class Runtime { Runtime.ScriptTransformer = ScriptTransformer; -export default Runtime; +module.exports = Runtime;