diff --git a/packages/react-test-renderer/npm/shallow.js b/packages/react-test-renderer/npm/shallow.js index 8c558b509a3c6..636c385d716b8 100644 --- a/packages/react-test-renderer/npm/shallow.js +++ b/packages/react-test-renderer/npm/shallow.js @@ -1,3 +1,8 @@ 'use strict'; -module.exports = require('react-shallow-renderer'); +var ReactShallowRenderer = require('react-shallow-renderer'); + +// This is hacky but makes it work with webpack preferring to load ESM +// even if imported via `require()`, and `react-shallow-renderer` ships with ESM. +// See https://github.com/webpack/webpack/issues/7973 +module.exports = ReactShallowRenderer.default || ReactShallowRenderer;