stitches icon indicating copy to clipboard operation
stitches copied to clipboard

Module import issue with Webpack 5

Open jnoer opened this issue 2 years ago • 4 comments

Bug report

Error with Create React App when stitches is a dependency of a dependency.

Uncaught TypeError: (0 , _react.createStitches) is not a function

This appears in react-scripts 5 (webpack 5), but not react-scripts 4 (webpack 4).

We have a storybook project that has stitches as a dependency. When we import components from that storybook project, Webpack seems to not be loading the stitches module. @stitches/react doesn't appear in Chrome DevTools node_modules. Storybook doesn't appear to be involved here.

Screen Shot 2022-07-08 at 1 11 14 PM

The _react variable above should resolve to a Module, but resolves to a path string with media in the path.

Screen Shot 2022-07-08 at 1 36 48 PM

To Reproduce

Minimal apps: https://github.com/jnoer/react-app

This is the package that has stitches as a dependency. It's pulled in by the above project. https://github.com/jnoer/storybook

Expected behavior

Error should not appear and things should work as with react-scripts 4

Screenshots

System information

  • OS: [macOS]
  • Browser (if applies) [Chrome]
  • Version of Stitches: [e.g. 1.2.8]
  • Version of Node.js: [16.15.1]

Additional context

Add any other context about the problem here.

jnoer avatar Jul 11 '22 20:07 jnoer

This seems to be the same issue as https://github.com/stitchesjs/stitches/issues/973

jnoer avatar Jul 16 '22 13:07 jnoer

I added a comment to this closed issue which is the same thing, but without a stitches.config.js: https://github.com/stitchesjs/stitches/issues/973

jnoer avatar Jul 17 '22 18:07 jnoer

Observing same thing in fresh repo after publishing a basic stitches lib bundled with rollup.

The repro on the library side is here:

https://github.com/TheeMattOliver/radix-stitches-styled-not-function-repro

The consumer's just a fresh CRA app

TheeMattOliver avatar Jul 29 '22 00:07 TheeMattOliver

Observing same thing in fresh repo after publishing a basic stitches lib bundled with rollup.

The repro on the library side is here:

https://github.com/TheeMattOliver/radix-stitches-styled-not-function-repro

The consumer's just a fresh CRA app

Have you managed to find a way around this? I've got exactly the same problem.

ChristopherMeek avatar Aug 11 '22 10:08 ChristopherMeek