Skip to content
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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/createRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ export async function createRollupConfig(
'**/*.test.ts',
'**/*.spec.tsx',
'**/*.test.tsx',
// storybook files
'**/*.stories.tsx',
Copy link
Contributor Author

@kylemh kylemh Apr 7, 2020

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] : [])

Copy link
Contributor Author

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:
Screen Shot 2020-04-07 at 1 53 08 AM

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...
Screen Shot 2020-04-07 at 1 56 39 AM

Copy link
Contributor Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

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

// TS defaults below
'node_modules',
'bower_components',
Expand Down