SB 5.3 + Declarative config + CRA + TS not working
See original GitHub issueDescribe 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:
- Clone https://github.com/Kamahl19/react-starter
- Migrate
config.tsx
&addons.ts
tomain.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());
- run
yarn add -D @storybook/preset-create-react-app
- run
yarn storybook
- 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:
- Created 4 years ago
- Comments:10 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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/
@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.