-
Notifications
You must be signed in to change notification settings - Fork 48
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
Bump @storybook/react
to ^7.4.2
#1656
Merged
yangwooseong
merged 19 commits into
channel-io:main
from
yangwooseong:feat/migrate-to-storybook-7
Oct 27, 2023
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ab3c0de
chore(deps): bump storybook to ^7.4.2 from ^6.5.16
yangwooseong 600eb1f
feat(storybook/config): auto migrate main file
yangwooseong f402821
feat(storybook): get rid of dynamic title and use optional title feature
yangwooseong c17235c
feat(storybook): resolve errors caused by component absense
yangwooseong 9c15669
fix(storybook): fix typo in Typography story
yangwooseong daa42b7
feat(storybook): run codemod to migrate to CSF3
yangwooseong f4751c4
feat(storybook): resolves type error caused by type inference
yangwooseong 363c394
feat(storybook): remove type assertion
yangwooseong 04420bc
feat(storybook): move options filed to be sibling of control field
yangwooseong 41c453b
chore(bezier-react): add changeset
yangwooseong 07b28c1
style(storybook): fix lint error
yangwooseong 6103b87
refactor(storybook): migrate main config file to typescript
yangwooseong 6b5dad9
chore(storybook): rm @storybook/addon-mdx-gfm since it is not used an…
yangwooseong 3aca1b3
refactor(storybook): use satisfies and enhance type inference in Alph…
yangwooseong 3b13193
feat(storybook): migrate preview to ts file
yangwooseong e89027b
refactor(storybook): rm duplication in config
yangwooseong 0c85f07
style(storybook): add new line
yangwooseong 4dad50d
Revert "chore(bezier-react): add changeset"
yangwooseong 7ea1b34
Merge branch 'main' into feat/migrate-to-storybook-7
yangwooseong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { dirname, join } from "path" | ||
|
||
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin' | ||
import { type StorybookConfig } from '@storybook/react-webpack5' | ||
|
||
function getAbsolutePath(value) { | ||
return dirname(require.resolve(join(value, "package.json"))) | ||
} | ||
|
||
const config: StorybookConfig = { | ||
stories: [ | ||
'../src/**/*.stories.(tsx|mdx)', | ||
], | ||
|
||
addons: [ | ||
getAbsolutePath("@storybook/addon-controls"), | ||
getAbsolutePath("@storybook/addon-actions"), | ||
getAbsolutePath("@storybook/addon-a11y"), | ||
getAbsolutePath("@storybook/addon-toolbars"), | ||
getAbsolutePath("@storybook/addon-docs"), | ||
getAbsolutePath("@storybook/addon-backgrounds"), | ||
], | ||
|
||
typescript: { | ||
/** | ||
* @note | ||
* | ||
* `react-docgen-typescript-plugin` introduces significant overhead | ||
* when HMR is enabled, so we enable it only in production. | ||
*/ | ||
reactDocgen: process.env.NODE_ENV === 'production' && 'react-docgen-typescript', | ||
reactDocgenTypescriptOptions: { | ||
shouldRemoveUndefinedFromOptional: true, | ||
shouldExtractLiteralValuesFromEnum: true, | ||
propFilter: (prop) => (prop.parent ? !/node_modules/.test(prop.parent.fileName) : true), | ||
}, | ||
}, | ||
|
||
webpackFinal: async (config) => { | ||
config.resolve = { | ||
...config.resolve, | ||
// Apply tsconfig alias path | ||
plugins: [ | ||
...(config?.resolve?.plugins ?? []), | ||
new TsconfigPathsPlugin({}), | ||
], | ||
extensions: [ | ||
...(config.resolve?.extensions ?? []), | ||
'.ts', | ||
'.tsx', | ||
] | ||
} | ||
Comment on lines
+39
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 중요하진 않지만, 나중에 Vite로 마이그레이션도 해볼만할 거 같아요. |
||
|
||
config.module = { | ||
...config.module, | ||
rules: [ | ||
...(config.module?.rules ?? []), { | ||
test: /\.(ts|tsx)$/, | ||
loader: require.resolve('babel-loader'), | ||
options: { | ||
presets: [['react-app', { flow: false, typescript: true }]], | ||
} | ||
} | ||
] | ||
} | ||
|
||
return config | ||
}, | ||
|
||
framework: { | ||
name: '@storybook/react-webpack5', | ||
options: {} | ||
}, | ||
|
||
docs: { | ||
autodocs: true | ||
} | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import type { Preview } from "@storybook/react" | ||
|
||
import { WithFoundationProvider } from './WithFoundationProvider' | ||
|
||
const preview: Preview = { | ||
decorators: [WithFoundationProvider], | ||
} | ||
|
||
export default preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WithFoundationProvider.jsx 를 tsx 로 변경하려면 tsconfig.include 에 파일을 포함시키고 rootDir를 '.' 로 해야되는데, 그러면 타입 빌드 결과가 달라지게 되서 jsx 그대로 두었습니다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
복잡한 설정 없이 타이핑 이점을 누리기 위해서 아예 preview.ts 내부로 옮기는 건 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
혹시
src/
폴더를 의미하신 걸까요?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.storybook/preview.ts
에요. 해당 파일안에 직접 작성하면 컴파일하지 않아도 괜찮지 않을까? 싶었습니다There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preview.ts
로 넣으면 path alias 를 사용못하게 되서../src/...
이런 식으로 import 를 해야하는데, 그렇게 하면Text
컴포넌트 타입을 다르게 읽어서 타입 에러가 뜹니다. 이 부분에 대한 원인을 찾지 못했습니다.