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[
    
  20.       `^schedule$`
    
  21.     ] = `<rootDir>/build/${NODE_MODULES_DIR}/schedule`;
    
  22.     moduleNameMapper[
    
  23.       '^schedule/tracing$'
    
  24.     ] = `<rootDir>/build/${NODE_MODULES_DIR}/schedule/tracing-profiling`;
    
  25.   }
    
  26. 
    
  27.   // react-dom/client is only in v18.0.0 and up, so we
    
  28.   // map it to react-dom instead
    
  29.   if (semver.satisfies(REACT_VERSION, '<18.0')) {
    
  30.     moduleNameMapper[
    
  31.       '^react-dom/client$'
    
  32.     ] = `<rootDir>/build/${NODE_MODULES_DIR}/react-dom`;
    
  33.   }
    
  34. 
    
  35.   setupFiles.push(require.resolve('./setupTests.build-devtools-regression'));
    
  36. }
    
  37. 
    
  38. module.exports = {
    
  39.   moduleNameMapper,
    
  40.   setupFiles,
    
  41. };