-
Notifications
You must be signed in to change notification settings - Fork 1k
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
add TS support for storybook preview tsx config extension #9309
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
120702e
feat: update storybook paths
bnn1 d5b9929
Merge branch 'main' of github.com:bnn1/redwood into 9118/storybook-ts…
bnn1 26cb17f
feat: create storybook tsx templates
bnn1 737feba
feat: update storybook template paths
bnn1 2fabf18
feat: remove storybook js templates
bnn1 2ca7f25
Merge branch 'main' of github.com:bnn1/redwood into 9118/storybook-ts…
bnn1 a20e396
feat: add support for ts/tsx files
bnn1 3953f32
feat: use tsx storybook template
bnn1 a373973
feat: read tsx storybook preview config if the project is ts
bnn1 1e3bf75
fix: failing tests
bnn1 1904f2a
revert: ts support for storybook manager and config files
bnn1 b57d724
Merge branch 'redwoodjs:main' into 9118/storybook-tsx-support
bnn1 19b6d79
Merge branch 'main' of github.com:bnn1/redwood into 9118/storybook-ts…
bnn1 8a292c0
revert: type annotations for js storybook preview files
bnn1 bc74dcf
Merge branch '9118/storybook-tsx-support' of github.com:bnn1/redwood …
bnn1 3f713a4
Merge branch 'main' of github.com:bnn1/redwood into 9118/storybook-ts…
bnn1 40aabfd
feat: include 'config' directory in web tsconfig
bnn1 a476d18
fix: regenerate fixtures, crwa, fix comment type
bnn1 2c5e9d0
fix: add backward compatibility for ts users
bnn1 6e124df
Merge branch 'main' of github.com:bnn1/redwood into 9118/storybook-ts…
bnn1 36a0323
fix: pr
bnn1 de828f0
fix: failing tests
bnn1 44bdd24
Merge branch 'main' into 9118/storybook-tsx-support
dac09 b1926bb
Merge branch 'redwoodjs:main' into 9118/storybook-tsx-support
bnn1 79ef0f0
fix: pr suggestions
bnn1 a0f91f6
feat: jsx/tsx/ts merge tests
bnn1 a91cc77
Merge branch 'main' into 9118/storybook-tsx-support
dac09 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 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
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
8 changes: 6 additions & 2 deletions
8
...ates/chakra.storybook.preview.js.template → ...tes/chakra.storybook.preview.tsx.template
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
6 changes: 5 additions & 1 deletion
6
...tes/mantine.storybook.preview.js.template → ...es/mantine.storybook.preview.tsx.template
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
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
16 changes: 0 additions & 16 deletions
16
packages/cli/src/lib/templates/storybook.preview.js.template
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
packages/cli/src/lib/templates/storybook.preview.tsx.template
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,18 @@ | ||
import * as React from 'react' | ||
|
||
import type { GlobalTypes } from '@storybook/csf' | ||
import type { StoryFn, StoryContext } from '@storybook/react' | ||
|
||
/** @type { import("@storybook/csf").GlobalTypes } */ | ||
export const globalTypes: GlobalTypes = {} | ||
|
||
/** | ||
* An example, no-op storybook decorator. Use a function like this to create decorators. | ||
* @param { import("@storybook/react").StoryFn} StoryFn | ||
* @param { import("@storybook/react").StoryContext} context | ||
*/ | ||
const _exampleDecorator = (StoryFn: StoryFn, _context: StoryContext) => { | ||
return <StoryFn /> | ||
} | ||
|
||
export const decorators = [] |
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
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.
Mind elaborating what this change was for please? I don't really have context, so hard to figure out :)
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.
Ah got it. So questions here:
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.
The change is necessary because
preset-react
won't work with TS files.Without the filename I get this error on the Redwood project. You're right about
@babel/preset-react
- it's not neededThere 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.
Hey, so I think this will fail when using
.js
files, because preset-typescript will only parse jsx when https://babeljs.io/docs/babel-preset-typescript#istsx is forced to true. I'm not 100% sure because of how themerge
is being used.My suggestion here:
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.
I've tested both ts and js projects manually, everything's working. I'll add unit tests.
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.
Ahhh... maybe because the filename has
.tsx
in it, it automatically enables JSX parsing!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.
Do you have an idea what tests to write? Merge two files and test that the merged file has contents of both files? I.e.
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.
I think the key thing to check would be that one of the files being merged having JSX in it.
Maybe the easiest way to test it would be to take a snippet of what you're actually merging and just have it as a test. The primary motivation here would be to prevent regression :)