| 1 | 'use strict'; |
| 2 | |
| 3 | const semver = require('semver'); |
| 4 | |
| 5 | const NODE_MODULES_DIR = |
| 6 | process.env.RELEASE_CHANNEL === 'stable' ? 'oss-stable' : 'oss-experimental'; |
| 7 | |
| 8 | const REACT_VERSION = process.env.REACT_VERSION; |
| 9 | |
| 10 | const moduleNameMapper = {}; |
| 11 | const setupFiles = []; |
| 12 | |
| 13 | // We only want to add these if we are in a regression test, IE if there |
| 14 | // is a REACT_VERSION specified |
| 15 | if (REACT_VERSION) { |
| 16 | // React version 16.5 has a schedule package instead of a scheduler |
| 17 | // package, so we need to rename them accordingly |
| 18 | if (semver.satisfies(REACT_VERSION, '16.5')) { |
| 19 | moduleNameMapper[`^schedule$`] = |
| 20 | `<rootDir>/build/${NODE_MODULES_DIR}/schedule`; |
| 21 | moduleNameMapper['^schedule/tracing$'] = |
| 22 | `<rootDir>/build/${NODE_MODULES_DIR}/schedule/tracing-profiling`; |
| 23 | } |
| 24 | |
| 25 | // react-dom/client is only in v18.0.0 and up, so we |
| 26 | // map it to react-dom instead |
| 27 | if (semver.satisfies(REACT_VERSION, '<18.0')) { |
| 28 | moduleNameMapper['^react-dom/client$'] = |
| 29 | `<rootDir>/build/${NODE_MODULES_DIR}/react-dom`; |
| 30 | } |
| 31 | |
| 32 | setupFiles.push(require.resolve('./setupTests.build-devtools-regression')); |
| 33 | } |
| 34 | |
| 35 | module.exports = { |
| 36 | moduleNameMapper, |
| 37 | setupFiles, |
| 38 | }; |