jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.24k stars 508 forks source link

yarn 2 compatibility #933

Open cspotcode opened 3 years ago

cspotcode commented 3 years ago

I'm starting to work on yarn 2 compatibility. I'll see how far I can get.

Try it out today

Yarn 2 users, you can try this branch today and let me know what does / does not work.

# Install this version of tsdx
yarn add tsdx@github:cspotcode/tsdx.git#yarn2
# Now you can use tsdx
yarn tsdx test

I am also working at this other PR so that I can push frequently for CI to run without spamming this thread: https://github.com/cspotcode/tsdx/pull/4

Changes I've had to make:

Related issues that may / may not need fixes

Simplifications since the last review

This is a list of undesirable changes from my initial submission that I have reverted

Related links: (note to self explain why they're relevant) https://github.com/facebook/jest/pull/10847 https://github.com/facebook/create-react-app/pull/5270

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

šŸ” Inspect: https://vercel.com/formium/tsdx/a53gz5xvv
āœ… Preview: https://tsdx-git-yarn2.formium.vercel.app

cspotcode commented 3 years ago

This PR is marked draft because it is still a work in progress, so it's expected to be broken. I created it so I could ping @merceyz who wanted to follow along.

cspotcode commented 3 years ago

I got all the tests passing in yarn2. PR is still marked "draft" because the yarn folks have sent a bugfix to jest that may allow me to simplify and speed up the changes I had to make here.

merceyz commented 3 years ago

rollup-plugin-pnp-resolve wasn't added but is mentioned in #688 (comment) and #458 (comment)

resolve, which is used by @rollup/plugin-node-resolve, has PnP support so that rollup plugin isn't needed anymore.

cspotcode commented 3 years ago

@agilgur5 thanks for taking a look, I'm working through the review feedback. I've left comments on a few things, am pushing fixes for some, and for other things like jest presets, I'll need to do some research.

It has been helpful to let Github Actions run the tests while I work, which is why I've been pushing code here as I go. Understanding that you've muted this thread, is it ok if I keep pushing code as I go? I can ping you only once I've addressed all review feedback.

cspotcode commented 3 years ago

I got rid of the npm misnomer and trimmed down the test matrix.

I've reverted the package.json changes. I did some testing and they were only necessary when running jest under PnP. In another branch I'm going to re-implement the changes to run jest under PnP, which should simplify the tests, eliminate some of the messier changes to test infra, and enable unit-testing. I'll see if/how many dependency changes are necessary.

timini commented 3 years ago

Great to see so much progress on this, if there is a list of follow up tasks that would be great to get some others to input on those.

I mentioned before I would like to sponsor such efforts and I'd like to honour that, please sign up for issuehunt!

cspotcode commented 3 years ago

@timini how does issuehunt work? Do I need to sign up, or does the tsdx team need to sign up?

As far as getting other people involved with the remaining work, I added a checklist of tasks to the issue description, but at the moment it's a bit messy. I am also iterating in another branch and merging to this PR when major improvements are ready. Trying to cut down on spam over here. https://github.com/cspotcode/tsdx/pull/4

Perhaps more useful than the checklist, I added instructions for installing and testing this version of tsdx today. Yarn 2 users, please feel free to give it a shot on your projects and let me know what's still broken.

timini commented 3 years ago

Tested creating a yarn 2 monorepo using workspaces. So far i have no issues, i had to setup a tsconfig.json at the workspace root which is extended by the workspace packages

https://github.com/timini/tsdx-yarn-2-monorepo

timini commented 3 years ago

I have done very minimal project setup so far, but it looked promising, its based off https://github.com/cspotcode/tsdx#yarn2

I haven't tried with main line tsdx.

Are there any tests i should make? Is it possible to add tests for this kind of monorepo setup?

timini commented 3 years ago

OK i tested the same setup using main branch tsdx and encountered issues with yarn install. It seems those issues are resolved by https://github.com/cspotcode/tsdx#yarn2

cspotcode commented 3 years ago

@timini the "changed I've had to make" section of the OP lists fixes I made for compatibility. The yarn2 bugfix has since been merged and released, so shouldn't be necessary any more. Are you using the latest stable yarn 2?