Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react_1.styled is not a function #973

Open
rwieruch opened this issue Feb 27, 2022 · 15 comments
Open

react_1.styled is not a function #973

rwieruch opened this issue Feb 27, 2022 · 15 comments
Labels
awaiting feedback Awaiting feedback bug Something isn't working

Comments

@rwieruch
Copy link

rwieruch commented Feb 27, 2022

I took the evening to migrate my library from using styled-components to stitches. When I start Storybook, the styles get applied perfectly. However, when I build the library and install it somewhere else, I get: react_1.styled is not a function. (see here).

This is the branch of my library where I am using stitches now: https://github.com/table-library/react-table-library/tree/feat/stitches Compared to using styled-components (or emotion), I thought I wouldn't have to change anything in the tsconfig.json or babel.config.js to make it work. Or am I wrong here? I am using rollup to bundle everything.

Thanks for your help! Really looking forward getting this to work!

@rwieruch
Copy link
Author

rwieruch commented Mar 1, 2022

Side-note: Wondering if it has something to do with @babel/runtime being needed, because radix-ui uses it as dependency too: https://github.com/radix-ui/primitives/blob/main/packages/react/checkbox/package.json

@arturbien
Copy link

Having the same issue. I am not using radix tho. The only dependencies I am using so far are react and stitches.

@rwieruch did you manage to get around this issue?

@rwieruch
Copy link
Author

rwieruch commented Mar 2, 2022

I am not using radix either. No, didn't find a solution yet. Worst case I have to use emotion instead, but I really hope to use stitches here :)

@hadihallak
Copy link
Member

Hey @rwieruch
Would you be able to provide us with a minimalistic reproduction of the issue (the smaller the repro, the faster we can debug it)?

@hadihallak hadihallak added bug Something isn't working awaiting feedback Awaiting feedback labels Jun 1, 2022
@rwieruch
Copy link
Author

rwieruch commented Jun 1, 2022

Hi @hadihallak I went with emotion in the meantime and don't have any project at my hands anymore. Feel free to close this if no one else comes up with this issue.

@hadihallak
Copy link
Member

@arturbien Do you still have this issue?

@arturbien
Copy link

@hadihallak we went with styled-components instead

@hadihallak
Copy link
Member

@arturbien Thanks for your quick response.
Will be closing this for now but if anyone else is having the issue, feel free to re-open this and post a minimal-repro

@jnoer
Copy link

jnoer commented Jul 17, 2022

I get the same with brand new minimal apps. This is a brand new create-react-app application with only storybook and Stitches installed. It exports one button:
https://github.com/jnoer/storybook/tree/no-stitches-config

Target application. It's a brand new create-react-app that imports the above button component:
https://github.com/jnoer/react-app/tree/no_stitches_config

I tested with Emotion instead of Stitches and that does work.

@hadihallak Can we reopen this?

I had opened this issue which is the same, but the error is a little different since it uses stitches.config.js.
#1061

@TheeMattOliver
Copy link

Please re-open.

Brand new minimal lib, using Stitches.

On the consumer side:

0 , _react.styled) is not a function

@hadihallak hadihallak reopened this Jul 26, 2022
@TheeMattOliver
Copy link

TheeMattOliver commented Jul 26, 2022

Originally I thought this might have to do with the fact that stitches.config.js was misconfigured or I had an import wrong, but after doublechecking and trying again, the error is similar

Error on consumer side:

Uncaught TypeError: (0 , _react.createStitches) is not a function
    at ./node_modules/<MY-LIB>/lib-esm/stitches.config.js (stitches.config.js:11:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/@groundgametexas/react/lib-esm/Box.js (Box.js:8:1)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:24:1)
    at fn (hot module replacement:62:1)
    at ./node_modules/<MY-LIB>/lib-esm/index.js (index.js:23:1)
    at options.factory (react refresh:6:1)

Repro:

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

@drigofonte
Copy link

drigofonte commented Aug 25, 2022

Hi there, getting a similar issue in our build pipeline where we get the following error message when running our tests:

TypeError: (0 , core_1.keyframes) is not a function

       5 | const colors = {};
       6 |
    >  7 | const spin = keyframes({
         |                       ^
       8 |   "0%": { transform: "rotate(0deg)" },
       9 |   "100%": { transform: "rotate(360deg)" },
      10 | });

      at Object.<anonymous> (base-ui/components/button/button.styles.ts:7:23)
      at Object.<anonymous> (base-ui/components/button/button.tsx:4:1)
      at Object.<anonymous> (base-ui/components/button/index.ts:1:1)
      at Object.<anonymous> (base-ui/components/badge/badge.spec.tsx:4:1)

Has anyone come up with a solution or explanation of what might be causing it?

Thanks.

@chrislicodes
Copy link

Any updates on this one?
Similar error on consumer side for a fresh CRA:

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

@jnoer
Copy link

jnoer commented Dec 1, 2022

React 18 is not supported. See #1059

We have switched over to Emotion.

@renecruces
Copy link

I've been experiencing the same problem. In my case, I've noticed that webpack was not including this package, and was importing the path to the .cjs module instead.

image

image

So I modified my babel config with the following in order to resolve the package accordingly:

module.exports = {
  ...
  plugins: [
    [
      'module-resolver', // https://www.npmjs.com/package/babel-plugin-module-resolver
      {
        root: ['./src'],
        alias: {
          '@stitches/react': path.resolve(__dirname, './node_modules/@stitches/react')
        }
      }
    ],
    ...
  ]
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Awaiting feedback bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants