From 1e98682dd383ca07f2819dc8987bd46cdb5fa028 Mon Sep 17 00:00:00 2001 From: Luna Ruan Date: Mon, 23 May 2022 14:18:17 -0700 Subject: [PATCH] [DevTools] Fix moduleNameMapper Order in DevTools Config #24602) We need the regression config moduleNameMapper to come before the current moduleNameMapper so when it tries to map "/^react-dom\/([^/]+)$/ it doesn't get confused. The reason is because order in which the mappings are defined matters. Patterns are checked one by one until one fits, and the most specific rule should be listed first. --- .../react-devtools-shared/src/__tests__/profilingCache-test.js | 2 +- scripts/jest/config.build-devtools.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-devtools-shared/src/__tests__/profilingCache-test.js b/packages/react-devtools-shared/src/__tests__/profilingCache-test.js index eb4a1aceba..1a84be03aa 100644 --- a/packages/react-devtools-shared/src/__tests__/profilingCache-test.js +++ b/packages/react-devtools-shared/src/__tests__/profilingCache-test.js @@ -734,7 +734,7 @@ describe('ProfilingCache', () => { } }); - // @reactVersion >= 16.9 + // @reactVersion >= 18.0 it('should calculate durations based on actual children (not filtered children)', () => { store.componentFilters = [utils.createDisplayNameFilter('^Parent$')]; diff --git a/scripts/jest/config.build-devtools.js b/scripts/jest/config.build-devtools.js index ecea02fa33..dd74a4ce98 100644 --- a/scripts/jest/config.build-devtools.js +++ b/scripts/jest/config.build-devtools.js @@ -51,8 +51,8 @@ moduleNameMapper['^react-reconciler/([^/]+)$'] = module.exports = Object.assign({}, baseConfig, { // Redirect imports to the compiled bundles moduleNameMapper: { - ...moduleNameMapper, ...devtoolsRegressionConfig.moduleNameMapper, + ...moduleNameMapper, }, // Don't run bundle tests on -test.internal.* files testPathIgnorePatterns: ['/node_modules/', '-test.internal.js$'],