-
Notifications
You must be signed in to change notification settings - Fork 508
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
(feat): exclude co-located stories by default from build #666
Conversation
@@ -154,6 +154,8 @@ export async function createRollupConfig( | |||
'**/*.test.ts', | |||
'**/*.spec.tsx', | |||
'**/*.test.tsx', | |||
// storybook files | |||
'**/*.stories.tsx', |
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 wonder if we need to do
...(!!opts.tsconfig.exclude ? [opts.tsconfig.exclude] : [])
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 tested the logic in rpts2:
I don't see an issue... it should work fine.
Although strangely enough a different merge loses some options which I'm surprised get lost...
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.
There exists a few lines after L44 in that rpts2 file I linked which I believe also do some merging.
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.
That's not because of rpts2 -- that's how _.merge
works with arrays. exclude
is an array, so your custom exclude would just override the same indices.
In your first "test", **/*.stories.tsx
also overrides the first entry, **/*.spec.ts
I think this jogged my brain a bit -- I'm pretty sure that line in rpts2 is around where the bug is.
TSDX has similar logic as rpts2 using TS's custom parsers to read a tsconfig
and then get its compilerOptions
through all extends
chains. But that's only for compilerOptions
, meaning exclude
etc from an extends
aren't actually parsed.
Problem there is that I don't know if there's a way to get the rest. This part of the TS API isn't documented but is used in lots of places in the wild for parsing, it took me a while to figure out how to do it myself, c.f. #489
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, the original config gets mutated with the new include
/exclude
, while compilerOptions
is unchanged and returned per facebook/create-react-app#5537
I'll have to look into rpts2 config and see if there's actually a bug or not, I'm not sure. I still haven't repro'd #663
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 still need to repro the bug, investigate, and then possibly investigate upstream, but I was thinking this feature is good to have in any case for simplifying config for those who have co-located stories. But this entire default exclude
wouldn't be needed if we could use file: ['src/index.ts']
instead, but that's blocked on ezolenko/rollup-plugin-typescript2#211.
In any case, this would need tests if it were to be merged. Would have to add an empty story file to the build-default
fixture (similar to the empty test/
files that just have comments in them) and then check that it's not output to dist/
after build
Sounds like I should just wait for ezolenko/rollup-plugin-typescript2#211 Thanks for diving deep! Love having you on this project. ❤️ |
I don't think that'll be fixed any time soon, especially not if it requires parsing declarations. Hence why I'd be fine with this going in, as, for the time-being we have to use |
I see. My guess is a relevant test would be considered e2e? I can do a default build with a Storybook file. Make a uniquely named type, and assert that none of the file contents in |
Yea you'd like create |
A brute attempt to resolve the issue I'm encountering in #663
Resolves #663