question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SB 5.3 + Declarative config + CRA + TS not working

See original GitHub issue

Describe the bug When I migrate from config.tsx & addons.ts to main.js & preview.tsx I get this error

ERROR in ./storybook/generated-entry.js
Module Error (from ./node_modules/eslint-loader/dist/cjs.js):
Line 3:15:  Import in body of module; reorder to top  import/first

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/Kamahl19/react-starter
  2. Migrate config.tsx & addons.ts to main.js
module.exports = {
  stories: ['../src/**/story.tsx'],
  presets: ['@storybook/preset-create-react-app'],
  addons: [
    '@storybook/addon-a11y',
    '@storybook/addon-actions',
    '@storybook/addon-knobs',
    '@storybook/addon-viewport',
  ],
};

preview.tsx

import React, { Suspense } from 'react';
import { makeDecorator } from '@storybook/addons';
import { addDecorator } from '@storybook/react';
import { withA11y } from '@storybook/addon-a11y';
import StoryRouter from 'storybook-react-router';

import 'common/services/i18next';
import 'app/styles/main.css';

addDecorator(withA11y);
addDecorator(
  makeDecorator({
    name: 'withI18Next',
    parameterName: 'i18Next',
    wrapper: (storyFn, context) => <Suspense fallback={<></>}>{storyFn(context)}</Suspense>,
  })
);
addDecorator(StoryRouter());
  1. run yarn add -D @storybook/preset-create-react-app
  2. run yarn storybook
  3. get the error in terminal

Expected behavior I believe I did everything according to the Docs & Migration guide, so it should just work i guess 😄

System:

  System:
    OS: macOS 10.15.2
    CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.18.0 - ~/.yarn/bin/yarn
    npm: 6.11.3 - ~/.nvm/versions/node/v10.16.3/bin/npm
  Browsers:
    Chrome: 79.0.3945.117
    Firefox: 67.0.4
    Safari: 13.0.4
  npmPackages:
    @storybook/addon-a11y: 5.3.0 => 5.3.0 
    @storybook/addon-actions: 5.3.0 => 5.3.0 
    @storybook/addon-knobs: 5.3.0 => 5.3.0 
    @storybook/addon-viewport: 5.3.0 => 5.3.0 
    @storybook/addons: 5.3.0 => 5.3.0 
    @storybook/preset-create-react-app: ^1.5.0 => 1.5.0 
    @storybook/react: 5.3.0 => 5.3.0 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
mrmckebcommented, Jan 12, 2020

Hi @Kamahl19, I was about to say the same thing - this was because Logo was not initialised. The error is correct 😃

Can I also recommend that you move this package to use our new templates (I’m also on the CRA team).

This way, you don’t need to update it to the latest version all the time. https://create-react-app.dev/docs/custom-templates/

1reaction
shilmancommented, Jan 12, 2020

@Kamahl19 Yeah we hope to support main.ts in a future version.

Thanks for the bug – I think I see the problem! Fix coming up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

create-react-app typescript global.d.ts file doesn't work
A simpler approach would be to export an empty object from your global.d.ts , like so: declare global { interface Window { config:...
Read more >
Storybook 6 Migration Guide
This step-by-step guide gets you upgraded to Storybook 6.0 (SB6). Every year we release a major version of Storybook.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found