react-sticky-box icon indicating copy to clipboard operation
react-sticky-box copied to clipboard

JSX Runtime.

Open christopher-becker opened this issue 3 years ago • 12 comments

Hi I am getting the following error inside a typescript project.

Error: ERROR in ./node_modules/react-sticky-box/dist/index.js 3:0-40 Module not found: Error: Can't resolve 'react/jsx-runtime' in '../node_modules/react-sticky-box/dist' Did you mean 'jsx-runtime.js'? BREAKING CHANGE: The request 'react/jsx-runtime' failed to resolve only because it was resolved as fully specified (probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"'). The extension in the request is mandatory for it to be fully specified. Add the extension to the request.

I am using a sample from the demo site: import StickyBox from "react-sticky-box"; <StickyBox offsetTop={90} offsetBottom={90}><div>Test</div></StickyBox>

christopher-becker avatar Mar 09 '23 07:03 christopher-becker

In the file: node_modules/react-sticky-box/dist/index.js

If I change this line import { jsx } from "react/jsx-runtime";

To: import { jsx } from "react/jsx-runtime.js";

Everything works. Obviously this is not ideal.

christopher-becker avatar Mar 09 '23 09:03 christopher-becker

+1 having the same issue

bmroot avatar Mar 12 '23 15:03 bmroot

What bundling system do you use? Vite? Webpack?

danielberndt avatar Mar 12 '23 15:03 danielberndt

I am using Webpack.

christopher-becker avatar Mar 13 '23 06:03 christopher-becker

@danielberndt I am using Nextjs 12 webpack 5

bmroot avatar Mar 13 '23 20:03 bmroot

I've just released v2.0.2 which should fix this issue

danielberndt avatar Apr 13 '23 20:04 danielberndt

i upgraded to the new version but still get same error deploying to vercel

Emmanuel-umeh avatar Apr 14 '23 01:04 Emmanuel-umeh

downgrading to 2.0.0 worked for me

Emmanuel-umeh avatar Apr 14 '23 02:04 Emmanuel-umeh

Yes had to release 2.0.3 to roll back the changes as it was breaking our internal build system as well. Not really sure what exactly to do from here. I was really not expecting that esm would be that complicated for such a simple setup with a single file and pretty much zero dependencies. 😅

danielberndt avatar Apr 14 '23 08:04 danielberndt

if you are using next.js , just do dynamic import with ssr disabled.

const StickyBox = dynamic(() => import('react-sticky-box'), {
  ssr: false,
});

billyen2012 avatar May 19 '23 05:05 billyen2012

this doesn't work for me.

wangdiee avatar Jun 12 '23 08:06 wangdiee

Hi! Is there any solution to the problem? I'm getting a similar error with Webpack. I tried different versions 2.0.0 - 2.0.5, it didn’t help.

upd. Downgrading to 1.0.2 helped.

xartv avatar Nov 22 '23 17:11 xartv