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

Using @storybook/theming in the preview imports emotion (and thus requires [email protected]) #5933

Closed
tmeasday opened this issue Mar 6, 2019 · 4 comments
Assignees
Milestone

Comments

@tmeasday
Copy link
Member

tmeasday commented Mar 6, 2019

Describe the bug
It seems import { create } from '@storybook/theming' ends up requiring emotion.

The error you'll see is

Uncaught TypeError: Object(...) is not a function
    at Module../node_modules/@emotion/core/dist/core.browser.esm.js (core.browser.esm.js:15)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../node_modules/@emotion/styled-base/dist/styled-base.browser.esm.js (styled-base.browser.esm.js:1)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Module../node_modules/@emotion/styled/dist/styled.browser.esm.js (styled.browser.esm.js:1)
    at __webpack_require__ (bootstrap:781)
    at fn (bootstrap:149)
    at Object../node_modules/@storybook/theming/dist/index.js (index.js:9)

To Reproduce

  1. Create a React@15 app
  2. import { create } from '@storybook/theming' in .storybook/config.js

Expected behavior
create is a simple function it shouldn't need to require emotion?

System:

  • Version: 5.0.0
@tmeasday tmeasday added this to the 5.0.x milestone Mar 6, 2019
@tmeasday tmeasday assigned ndelangen and unassigned tmeasday Mar 7, 2019
@tmeasday
Copy link
Member Author

tmeasday commented Mar 7, 2019

Do we still need the emotion exports in base.ts? (animation / easing)? I was under the impression we weren't using them.

My proposal here is to create a lib/theming/preview.ts file which only imports/exports the non-emotion stuff. Then users can import { create } from '@storybook/theming/preview';

That seems like the back-compat way to fix this. A non-back compat way would be to remove the emotion exports from the index.ts entrypoint and add a second one for those.

@tmeasday
Copy link
Member Author

tmeasday commented Mar 8, 2019

Discussed this a little with @ndelangen (who is a little out-of-action the last day or so) and generally he agreed on the approach. I think he is better placed to pull the pieces apart here.

@shilman
Copy link
Member

shilman commented Apr 15, 2019

Closing this as a dupe to #6474 since I created a repro there (didn't realize this had already been filed otherwise I would've just added to this issue.

@shilman shilman closed this as completed Apr 15, 2019
@github-actions
Copy link
Contributor

Automention: Hey @domyen @ndelangen, you've been tagged! Can you give a hand here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants