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

packages,plugins: point types to src/ for development #864

Merged
merged 2 commits into from
May 14, 2020
Merged

Conversation

Rugvip
Copy link
Member

@Rugvip Rugvip commented May 14, 2020

First and most obvious build setup fix coming out of #834

So my initial approach was to do this through publishConfig, docs for that are here. Turns out that their main docs point to the unreleased yarn v2 though, and that feature doesn't exist yet ¯\(ツ)/¯.

Looked though some 10 monrepos you there, mostly from https://github.com/brillout/awesome-react-components. Can't find any repo that has separate types config for published packages, so no prior art for this T_T

I'm thinking that adding pre-/post-pack scripts is the cleanest way to go about this for now. If we switch to yarn 2 me might be able to remove them. Or if we switch to pnpm who's had the feature for ages 😁

The postpack script also doesn't get called right now, bug in yarn, yarnpkg/yarn#7924, so publishing or trying out pack locally leaves some garbage in the packages.

@Rugvip Rugvip requested a review from a team as a code owner May 14, 2020 12:27
const pkgPath = paths.resolveTarget('package.json');

const pkg = await fs.readJson(pkgPath);
pkg.types = 'src/index.ts';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could have been served a bit cleaner as doing a backup in a secret dotfile, and restoring from that backup. That would not give unintended changes if the user has a slightly different thing going on in their file (other indent or whatever)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I presume there was no way to make this happen silently inside build? It would just be nice to not have so much boilerplate in the package files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah opted for just making sure type field exists everywhere instead of backup/restore. That would've been a bit annoying to deal with too imo, especially since the postpack script doesn't work 😁.

And no, afaik there's no way to silently hook into the process. I mean we could modify the yarn implementation we check into the repo, but nooooooooooo x)

@Rugvip Rugvip merged commit a82d2a5 into master May 14, 2020
@Rugvip Rugvip deleted the rugvip/srct branch May 14, 2020 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants