diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d338591b0e1..b03eafa0916e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features +- `[jest-haste-map]` Expose `throwOnModuleCollision` via `config.haste` ([#8113](https://github.com/facebook/jest/pull/8113)) + ### Fixes ### Chore & Maintenance diff --git a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap index 93748d2d53f6..8b27dc1ba115 100644 --- a/e2e/__tests__/__snapshots__/showConfig.test.ts.snap +++ b/e2e/__tests__/__snapshots__/showConfig.test.ts.snap @@ -24,7 +24,8 @@ exports[`--showConfig outputs config info and exits 1`] = ` "globals": {}, "haste": { "computeSha1": false, - "providesModuleNodeModules": [] + "providesModuleNodeModules": [], + "throwOnModuleCollision": false }, "moduleDirectories": [ "node_modules" diff --git a/packages/jest-config/src/Defaults.ts b/packages/jest-config/src/Defaults.ts index b25ff9c149c0..10fed37c6da5 100644 --- a/packages/jest-config/src/Defaults.ts +++ b/packages/jest-config/src/Defaults.ts @@ -38,6 +38,7 @@ const defaultOptions: Config.DefaultOptions = { haste: { computeSha1: false, providesModuleNodeModules: [], + throwOnModuleCollision: false, }, maxConcurrency: 5, moduleDirectories: ['node_modules'], diff --git a/packages/jest-config/src/ValidConfig.ts b/packages/jest-config/src/ValidConfig.ts index 1aec66632ba7..fb25df1599bc 100644 --- a/packages/jest-config/src/ValidConfig.ts +++ b/packages/jest-config/src/ValidConfig.ts @@ -57,6 +57,7 @@ const initialOptions: Config.InitialOptions = { hasteImplModulePath: '/haste_impl.js', platforms: ['ios', 'android'], providesModuleNodeModules: ['react', 'react-native'], + throwOnModuleCollision: false, }, json: false, lastCommit: false, diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index 83b327d12786..35df1bf43773 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -248,6 +248,7 @@ class Runtime { retainAllFiles: false, rootDir: config.rootDir, roots: config.roots, + throwOnModuleCollision: config.haste.throwOnModuleCollision, useWatchman: options && options.watchman, watch: options && options.watch, }); diff --git a/packages/jest-types/src/Config.ts b/packages/jest-types/src/Config.ts index d0b958ee9e44..76e4d06ef343 100644 --- a/packages/jest-types/src/Config.ts +++ b/packages/jest-types/src/Config.ts @@ -17,6 +17,7 @@ export type HasteConfig = { hasteImplModulePath?: string; platforms?: Array; providesModuleNodeModules: Array; + throwOnModuleCollision?: boolean; }; export type ReporterConfig = [string, {[key: string]: unknown}]; diff --git a/types/Config.js b/types/Config.js index 375278326abb..e3689ef3db5e 100644 --- a/types/Config.js +++ b/types/Config.js @@ -16,6 +16,7 @@ export type HasteConfig = {| hasteImplModulePath?: string, platforms?: Array, providesModuleNodeModules: Array, + throwOnModuleCollision?: boolean, |}; export type ReporterConfig = [string, Object];