rsnext/test/lib/react-17-require-hook.js
JJ Kasper 4a7ab34baf
Update repo to use react 18 by default (#35888)
This updates our `yarn next` command to leverage react v18 by default and removes the need for the test require hook/config modifying when testing react 18. There are some fixtures we need to investigate react 18 support in follow-ups:

- `test/integration/client-navigation-a11y`
- `test/integration/critical-css`
- `test/integration/custom-error-page-exception`
- `test/integration/font-optimization`
- AMP specific tests
2022-04-05 21:51:47 +00:00

17 lines
623 B
JavaScript

const mod = require('module')
const hookPropertyMap = new Map([
['react', 'react-17'],
['react/jsx-runtime', 'react-17/jsx-runtime'],
['react/jsx-dev-runtime', 'react-17/jsx-dev-runtime'],
['react-dom', 'react-dom-17'],
['react-dom/server', 'react-dom-17/server'],
['react-dom/server.browser', 'react-dom-17/server.browser'],
])
const resolveFilename = mod._resolveFilename
mod._resolveFilename = function (request, parent, isMain, options) {
const hookResolved = hookPropertyMap.get(request)
if (hookResolved) request = hookResolved
return resolveFilename.call(mod, request, parent, isMain, options)
}