From 4c30b1ebc70cfb231dd1a2c3e10afb7cf340e6d4 Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sat, 25 Jan 2020 19:42:25 +0500 Subject: [PATCH 01/11] Override module.createRequire --- .../__tests__/runtime_require_module.test.js | 13 ++++++++ .../test_root/create_require_module.js | 10 ++++++ packages/jest-runtime/src/index.ts | 33 ++++++++++++++++--- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 packages/jest-runtime/src/__tests__/test_root/create_require_module.js diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 4f678f9daac2..83ff1defde72 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -8,6 +8,7 @@ 'use strict'; +import {builtinModules, createRequire} from 'module'; import path from 'path'; // eslint-disable-next-line import/default import slash from 'slash'; @@ -347,4 +348,16 @@ describe('Runtime requireModule', () => { ); expect(exports.isJSONModuleEncodedInUTF8WithBOM).toBe(true); })); + + it('overrides module.createRequire', () => + createRuntime(__filename).then(runtime => { + const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); + + expect(exports.createRequire).not.toBe(createRequire); + const customRequire = exports.createRequire(runtime.__mockRootPath); + expect(customRequire('./create_require_module').foo).toBe('foo'); + + expect(exports.syncBuiltinESMExports).not.toThrow(); + expect(exports.builtinModules).toEqual(builtinModules); + })); }); diff --git a/packages/jest-runtime/src/__tests__/test_root/create_require_module.js b/packages/jest-runtime/src/__tests__/test_root/create_require_module.js new file mode 100644 index 000000000000..3d4f063e647f --- /dev/null +++ b/packages/jest-runtime/src/__tests__/test_root/create_require_module.js @@ -0,0 +1,10 @@ +/** + * 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. + */ + +'use strict'; + +module.exports.foo = 'foo'; diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 7ff305104da9..0d7d7afc7ba1 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -17,13 +17,9 @@ import { ModuleWrapper, } from '@jest/environment'; import {SourceMapRegistry} from '@jest/source-map'; -import jestMock = require('jest-mock'); -import HasteMap = require('jest-haste-map'); import {formatStackTrace, separateMessageFromStack} from 'jest-message-util'; -import Resolver = require('jest-resolve'); import {createDirectory, deepCyclicCopy} from 'jest-util'; import {escapePathForRegex} from 'jest-regex-util'; -import Snapshot = require('jest-snapshot'); import { ScriptTransformer, ShouldInstrumentOptions, @@ -35,11 +31,16 @@ import { import {V8CoverageResult} from '@jest/test-result'; import {CoverageInstrumenter, V8Coverage} from 'collect-v8-coverage'; import * as fs from 'graceful-fs'; -import stripBOM = require('strip-bom'); import {run as cliRun} from './cli'; import {options as cliOptions} from './cli/args'; import {findSiblingsWithFileExtension} from './helpers'; import {Context as JestContext} from './types'; +import jestMock = require('jest-mock'); +import HasteMap = require('jest-haste-map'); +import Resolver = require('jest-resolve'); +import Snapshot = require('jest-snapshot'); +import stripBOM = require('strip-bom'); +import { builtinModules } from 'module'; type HasteMapOptions = { console?: Console; @@ -887,6 +888,28 @@ class Runtime { return this._environment.global.process; } + if (moduleName === 'module') { + const createRequire = (modulePath: string) => + this._createRequireImplementation({ + children: [], + exports: {}, + filename: modulePath, + id: modulePath, + loaded: false, + }); + return { + builtinModules, + createRequire, + createRequireFromPath: (modulePath: string) => { + console.info( + '[DEP0130] DeprecationWarning: Module.createRequireFromPath() is deprecated. Use Module.createRequire() instead.', + ); + return createRequire(modulePath); + }, + syncBuiltinESMExports() {}, + }; + } + return require(moduleName); } From 5c7ea59b640357c8e394cd540a296e96d4e14b4e Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sun, 26 Jan 2020 18:50:51 +0500 Subject: [PATCH 02/11] Override module.createRequire --- .../__tests__/runtime_require_module.test.js | 37 ++++++++++----- packages/jest-runtime/src/index.ts | 46 ++++++++++++------- 2 files changed, 56 insertions(+), 27 deletions(-) diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 83ff1defde72..75e528d12eb1 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -12,6 +12,7 @@ import {builtinModules, createRequire} from 'module'; import path from 'path'; // eslint-disable-next-line import/default import slash from 'slash'; +import {onNodeVersions} from '@jest/test-utils'; let createRuntime; @@ -349,15 +350,29 @@ describe('Runtime requireModule', () => { expect(exports.isJSONModuleEncodedInUTF8WithBOM).toBe(true); })); - it('overrides module.createRequire', () => - createRuntime(__filename).then(runtime => { - const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); - - expect(exports.createRequire).not.toBe(createRequire); - const customRequire = exports.createRequire(runtime.__mockRootPath); - expect(customRequire('./create_require_module').foo).toBe('foo'); - - expect(exports.syncBuiltinESMExports).not.toThrow(); - expect(exports.builtinModules).toEqual(builtinModules); - })); + onNodeVersions('>=12.12.0', () => { + it('overrides module.createRequire', () => + createRuntime(__filename).then(runtime => { + const exports = runtime.requireModule(runtime.__mockRootPath, 'module'); + + expect(exports.createRequire).not.toBe(createRequire); + + // createRequire with string + { + const customRequire = exports.createRequire(runtime.__mockRootPath); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } + + // createRequire with URL + { + const customRequire = exports.createRequire( + new URL(runtime.__mockRootPath, 'file:'), + ); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } + + expect(exports.syncBuiltinESMExports).not.toThrow(); + expect(exports.builtinModules).toEqual(builtinModules); + })); + }); }); diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 0d7d7afc7ba1..92d74f22133b 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -5,9 +5,10 @@ * LICENSE file in the root directory of this source tree. */ +import {URL, fileURLToPath} from 'url'; import * as path from 'path'; import {Script, compileFunction} from 'vm'; -import {fileURLToPath} from 'url'; +import * as nativeModule from 'module'; import {Config} from '@jest/types'; import { Jest, @@ -40,7 +41,6 @@ import HasteMap = require('jest-haste-map'); import Resolver = require('jest-resolve'); import Snapshot = require('jest-snapshot'); import stripBOM = require('strip-bom'); -import { builtinModules } from 'module'; type HasteMapOptions = { console?: Console; @@ -889,25 +889,39 @@ class Runtime { } if (moduleName === 'module') { - const createRequire = (modulePath: string) => - this._createRequireImplementation({ + const createRequire = (modulePath: string | URL) => { + const filename = + typeof modulePath === 'string' + ? modulePath + : fileURLToPath(modulePath); + + return this._createRequireImplementation({ children: [], exports: {}, - filename: modulePath, - id: modulePath, + filename, + id: filename, loaded: false, }); - return { - builtinModules, - createRequire, - createRequireFromPath: (modulePath: string) => { - console.info( - '[DEP0130] DeprecationWarning: Module.createRequireFromPath() is deprecated. Use Module.createRequire() instead.', - ); - return createRequire(modulePath); - }, - syncBuiltinESMExports() {}, }; + + const overriddenModule = {...nativeModule}; + + if ('createRequire' in nativeModule) { + Object.defineProperty(overriddenModule, 'createRequire', { + value: createRequire, + }); + } + if ('createRequireFromPath' in nativeModule) { + Object.defineProperty(overriddenModule, 'createRequireFromPath', { + value: (filename: string) => createRequire(filename), + }); + } + if ('syncBuiltinESMExports' in nativeModule) { + Object.defineProperty(overriddenModule, 'syncBuiltinESMExports', { + value: () => {}, + }); + } + return overriddenModule; } return require(moduleName); From 83f45225001740af537a3965c6adbbe6e4c60070 Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sun, 26 Jan 2020 18:51:51 +0500 Subject: [PATCH 03/11] Override module.createRequire --- .../src/__tests__/runtime_require_module.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 75e528d12eb1..2beb6c33a5f3 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -371,6 +371,13 @@ describe('Runtime requireModule', () => { expect(customRequire('./create_require_module').foo).toBe('foo'); } + { + const customRequire = exports.createRequireFromPath( + runtime.__mockRootPath, + ); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } + expect(exports.syncBuiltinESMExports).not.toThrow(); expect(exports.builtinModules).toEqual(builtinModules); })); From 3aff3cd344825c3723db09475a09cbb713326646 Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sun, 26 Jan 2020 21:12:10 +0500 Subject: [PATCH 04/11] Override module.createRequire --- .../jest-runtime/src/__tests__/runtime_require_module.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 2beb6c33a5f3..e2129e727b74 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -10,6 +10,7 @@ import {builtinModules, createRequire} from 'module'; import path from 'path'; +import {pathToFileURL} from 'url'; // eslint-disable-next-line import/default import slash from 'slash'; import {onNodeVersions} from '@jest/test-utils'; @@ -366,7 +367,7 @@ describe('Runtime requireModule', () => { // createRequire with URL { const customRequire = exports.createRequire( - new URL(runtime.__mockRootPath, 'file:'), + pathToFileURL(runtime.__mockRootPath), ); expect(customRequire('./create_require_module').foo).toBe('foo'); } From af973091ad22aaf1fbc4429099f4390606c0ac52 Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sat, 1 Feb 2020 16:04:02 +0500 Subject: [PATCH 05/11] Override module.createRequire --- .../__tests__/runtime_require_module.test.js | 35 +++++++++++++++- packages/jest-runtime/src/index.ts | 40 +++++++++++++------ yarn.lock | 7 +++- 3 files changed, 68 insertions(+), 14 deletions(-) diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index e2129e727b74..41a9870d9467 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -364,7 +364,7 @@ describe('Runtime requireModule', () => { expect(customRequire('./create_require_module').foo).toBe('foo'); } - // createRequire with URL + // createRequire with URL object { const customRequire = exports.createRequire( pathToFileURL(runtime.__mockRootPath), @@ -372,6 +372,28 @@ describe('Runtime requireModule', () => { expect(customRequire('./create_require_module').foo).toBe('foo'); } + // createRequire with file URL string + { + const customRequire = exports.createRequire( + pathToFileURL(runtime.__mockRootPath).toString(), + ); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } + + // createRequire with absolute module path + { + const customRequire = exports.createRequire(runtime.__mockRootPath); + expect(customRequire('./create_require_module').foo).toBe('foo'); + } + + // createRequire with relative module path + expect(() => exports.createRequireFromPath('./relative/path')).toThrow( + new TypeError( + `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received './relative/path'`, + ), + ); + + // createRequireFromPath with absolute module path { const customRequire = exports.createRequireFromPath( runtime.__mockRootPath, @@ -379,6 +401,17 @@ describe('Runtime requireModule', () => { expect(customRequire('./create_require_module').foo).toBe('foo'); } + // createRequireFromPath with file URL object + expect(() => + exports.createRequireFromPath(pathToFileURL(runtime.__mockRootPath)), + ).toThrow( + new TypeError( + `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be string. Received '${pathToFileURL( + runtime.__mockRootPath, + )}'. Use createRequire for URL filename.`, + ), + ); + expect(exports.syncBuiltinESMExports).not.toThrow(); expect(exports.builtinModules).toEqual(builtinModules); })); diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 92d74f22133b..f88202789415 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -892,9 +892,17 @@ class Runtime { const createRequire = (modulePath: string | URL) => { const filename = typeof modulePath === 'string' - ? modulePath + ? modulePath.startsWith('file:///') + ? fileURLToPath(new URL(modulePath)) + : modulePath : fileURLToPath(modulePath); + if (!path.isAbsolute(filename)) { + throw new TypeError( + `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '${filename}'`, + ); + } + return this._createRequireImplementation({ children: [], exports: {}, @@ -904,24 +912,32 @@ class Runtime { }); }; - const overriddenModule = {...nativeModule}; + const overriddenModules: Partial = {}; if ('createRequire' in nativeModule) { - Object.defineProperty(overriddenModule, 'createRequire', { - value: createRequire, - }); + overriddenModules.createRequire = createRequire; } if ('createRequireFromPath' in nativeModule) { - Object.defineProperty(overriddenModule, 'createRequireFromPath', { - value: (filename: string) => createRequire(filename), - }); + overriddenModules.createRequireFromPath = (filename: string | URL) => { + if (typeof filename !== 'string') { + throw new TypeError( + `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be string. Received '${filename}'.${ + filename instanceof URL + ? ' Use createRequire for URL filename.' + : '' + }`, + ); + } + return createRequire(filename); + }; } if ('syncBuiltinESMExports' in nativeModule) { - Object.defineProperty(overriddenModule, 'syncBuiltinESMExports', { - value: () => {}, - }); + overriddenModules.syncBuiltinESMExports = () => {}; } - return overriddenModule; + + return Object.keys(overriddenModules).length > 0 + ? {...nativeModule, ...overriddenModules} + : nativeModule; } return require(moduleName); diff --git a/yarn.lock b/yarn.lock index fad3845025a4..5dc515a9495d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2164,7 +2164,12 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@>= 8": +"@types/node@*": + version "13.7.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" + integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== + +"@types/node@>= 8": version "13.1.8" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b" integrity sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A== From e0dab932fda5affad33f6cc5733de4cfc07fd27e Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sat, 1 Feb 2020 17:08:51 +0500 Subject: [PATCH 06/11] Override module.createRequire --- .../src/__tests__/runtime_require_module.test.js | 4 ++-- packages/jest-runtime/src/index.ts | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js index 41a9870d9467..4e79a11419f9 100644 --- a/packages/jest-runtime/src/__tests__/runtime_require_module.test.js +++ b/packages/jest-runtime/src/__tests__/runtime_require_module.test.js @@ -389,7 +389,7 @@ describe('Runtime requireModule', () => { // createRequire with relative module path expect(() => exports.createRequireFromPath('./relative/path')).toThrow( new TypeError( - `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received './relative/path'`, + `The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received './relative/path'`, ), ); @@ -406,7 +406,7 @@ describe('Runtime requireModule', () => { exports.createRequireFromPath(pathToFileURL(runtime.__mockRootPath)), ).toThrow( new TypeError( - `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be string. Received '${pathToFileURL( + `The argument 'filename' must be string. Received '${pathToFileURL( runtime.__mockRootPath, )}'. Use createRequire for URL filename.`, ), diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index f88202789415..cb74daf324af 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -898,9 +898,12 @@ class Runtime { : fileURLToPath(modulePath); if (!path.isAbsolute(filename)) { - throw new TypeError( - `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '${filename}'`, + const error = new TypeError( + `The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received '${filename}'`, ); + // @ts-ignore + error.code = 'ERR_INVALID_ARG_TYPE'; + throw error; } return this._createRequireImplementation({ @@ -920,13 +923,16 @@ class Runtime { if ('createRequireFromPath' in nativeModule) { overriddenModules.createRequireFromPath = (filename: string | URL) => { if (typeof filename !== 'string') { - throw new TypeError( - `[ERR_INVALID_ARG_VALUE] The argument 'filename' must be string. Received '${filename}'.${ + const error = new TypeError( + `The argument 'filename' must be string. Received '${filename}'.${ filename instanceof URL ? ' Use createRequire for URL filename.' : '' }`, ); + // @ts-ignore + error.code = 'ERR_INVALID_ARG_TYPE'; + throw error; } return createRequire(filename); }; From 6911e7286568fe4cc279c98b105c91a2901c97c9 Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sat, 1 Feb 2020 17:28:37 +0500 Subject: [PATCH 07/11] Override module.createRequire --- packages/jest-runtime/src/index.ts | 2 +- yarn.lock | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index cb74daf324af..ab22ea07b022 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -915,7 +915,7 @@ class Runtime { }); }; - const overriddenModules: Partial = {}; + const overriddenModules: Record = {}; if ('createRequire' in nativeModule) { overriddenModules.createRequire = createRequire; diff --git a/yarn.lock b/yarn.lock index d8017cdcf6c5..857ae62aa0d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2243,12 +2243,7 @@ dependencies: "@types/node" "*" -"@types/node@*": - version "13.7.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" - integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== - -"@types/node@>= 8": +"@types/node@*", "@types/node@>= 8": version "13.1.8" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b" integrity sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A== From 6c1fcfa8cec0b3272f56eee51d1e2ad5f0747036 Mon Sep 17 00:00:00 2001 From: doniyor2109 Date: Sat, 1 Feb 2020 17:37:03 +0500 Subject: [PATCH 08/11] Override module.createRequire --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 857ae62aa0d6..2cbfd77e2c0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2244,9 +2244,9 @@ "@types/node" "*" "@types/node@*", "@types/node@>= 8": - version "13.1.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b" - integrity sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A== + version "13.5.2" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.5.2.tgz#3de53b55fd39efc428a901a0f6db31f761cfa131" + integrity sha512-Fr6a47c84PRLfd7M7u3/hEknyUdQrrBA6VoPmkze0tcflhU5UnpWEX2kn12ktA/lb+MNHSqFlSiPHIHsaErTPA== "@types/prettier@^1.16.1": version "1.19.0" From 9f2078fd07c1a45725b3d77141c2e6305e46f8bc Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 1 Feb 2020 15:27:01 +0100 Subject: [PATCH 09/11] Revert "Override module.createRequire" This reverts commit 6c1fcfa8cec0b3272f56eee51d1e2ad5f0747036. --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2cbfd77e2c0a..857ae62aa0d6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2244,9 +2244,9 @@ "@types/node" "*" "@types/node@*", "@types/node@>= 8": - version "13.5.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.5.2.tgz#3de53b55fd39efc428a901a0f6db31f761cfa131" - integrity sha512-Fr6a47c84PRLfd7M7u3/hEknyUdQrrBA6VoPmkze0tcflhU5UnpWEX2kn12ktA/lb+MNHSqFlSiPHIHsaErTPA== + version "13.1.8" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b" + integrity sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A== "@types/prettier@^1.16.1": version "1.19.0" From 6d66dfaeadb9767739d6997e11b3b6d8e6b1b82c Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 1 Feb 2020 15:27:04 +0100 Subject: [PATCH 10/11] Revert "Override module.createRequire" This reverts commit 6911e7286568fe4cc279c98b105c91a2901c97c9. --- packages/jest-runtime/src/index.ts | 2 +- yarn.lock | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index ab22ea07b022..cb74daf324af 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -915,7 +915,7 @@ class Runtime { }); }; - const overriddenModules: Record = {}; + const overriddenModules: Partial = {}; if ('createRequire' in nativeModule) { overriddenModules.createRequire = createRequire; diff --git a/yarn.lock b/yarn.lock index 857ae62aa0d6..d8017cdcf6c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2243,7 +2243,12 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@>= 8": +"@types/node@*": + version "13.7.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" + integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== + +"@types/node@>= 8": version "13.1.8" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b" integrity sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A== From ecce093df2552563d37cefe61302fbc54418e90d Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sat, 1 Feb 2020 15:27:42 +0100 Subject: [PATCH 11/11] single types/node --- yarn.lock | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index d8017cdcf6c5..e9f45689142b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2243,16 +2243,11 @@ dependencies: "@types/node" "*" -"@types/node@*": +"@types/node@*", "@types/node@>= 8": version "13.7.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4" integrity sha512-GnZbirvmqZUzMgkFn70c74OQpTTUcCzlhQliTzYjQMqg+hVKcDnxdL19Ne3UdYzdMA/+W3eb646FWn/ZaT1NfQ== -"@types/node@>= 8": - version "13.1.8" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.8.tgz#1d590429fe8187a02707720ecf38a6fe46ce294b" - integrity sha512-6XzyyNM9EKQW4HKuzbo/CkOIjn/evtCmsU+MUM1xDfJ+3/rNjBttM1NgN7AOQvN6tP1Sl1D1PIKMreTArnxM9A== - "@types/prettier@^1.16.1": version "1.19.0" resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-1.19.0.tgz#a2502fb7ce9b6626fdbfc2e2a496f472de1bdd05"