From a20a2355b08193fc4f8cde6dec85602ead7229df Mon Sep 17 00:00:00 2001 From: Arjun <14841132+arjunvegda@users.noreply.github.com> Date: Fri, 10 Feb 2023 10:22:36 -0500 Subject: [PATCH] fix: inject react shim to the build --- .eslintignore | 3 ++- react-shim.js | 3 +++ tsup.config.ts | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 react-shim.js diff --git a/.eslintignore b/.eslintignore index 15b3d9dd..4d898402 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,4 +2,5 @@ dist node_modules build .eslintrc.js -coverage \ No newline at end of file +coverage +react-shim.js \ No newline at end of file diff --git a/react-shim.js b/react-shim.js new file mode 100644 index 00000000..71672e7b --- /dev/null +++ b/react-shim.js @@ -0,0 +1,3 @@ +// Why? See - https://github.com/egoist/tsup/issues/792 +import React from 'react'; +export { React }; diff --git a/tsup.config.ts b/tsup.config.ts index 8c7a4c44..2ccd95a1 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -30,6 +30,9 @@ const baseConfig: Options = { platform: 'node', outExtension: defaultOutExtension, esbuildPlugins: defaultEsBuildPlugins, + // TSUP does not appear to be respecting tsconfig's jsx property + // See - https://github.com/egoist/tsup/issues/792 + inject: ['./react-shim.js'], }; const cjsConfig: Options = {