From 492020c802b12c5d7bb9b7349eb72cc78aad69de Mon Sep 17 00:00:00 2001 From: Minh Nguyen Date: Sat, 29 Feb 2020 01:27:38 +0000 Subject: [PATCH] Add a fallback for ESM in react-test-renderer/shallow See https://github.com/webpack/webpack/issues/7973 --- packages/react-test-renderer/npm/shallow.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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;