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: Migrate to pnpm #9516

Merged
merged 12 commits into from Dec 5, 2022
Merged

🔨 feat: Migrate to pnpm #9516

merged 12 commits into from Dec 5, 2022

Conversation

nvh95
Copy link
Contributor

@nvh95 nvh95 commented Dec 4, 2022

Description

  • pnpm is faster and consumes less disk storage. Why don't use it? 😁

Related PR(s)

Features

  • Replace yarn by pnpm
  • Testing scripts:
    • clean
    • prebuild
    • build
    • postbuild
    • build:modern
    • build:esm
    • prettier:fix
    • lint
    • lint:fix
    • type
    • coverage (TODO: Check if it fails with yarn)
    • jest-preview
    • test
    • test:coverage
    • test:watch
    • test:web
    • test:server
    • test:native
    • tsd
    • e2e
    • e2e:watch
    • api-extractor (TODO: Warning: You have changed the public API signature for this project. Updating reports/api-extractor.md)
    • api-extractor:build
    • api-extractor:ci
    • postversion (I guess it's not needed)
    • prepublishOnly
    • bundlewatch
    • start
  • Update GitHub Actions
    • api-extrator
    • build-test
    • automation
    • compressed-size

Chores

  • Add build:watch script
  • Upgrade to vite@3 for app

@codesandbox
Copy link

codesandbox bot commented Dec 4, 2022

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 4, 2022

TODO:
To handle app folder when development, we have following options

  • Keep it as is, just link react and react-hook-form
  • Use pnpm workspace
  • Define "react-hook-form": "file:..", in app/package.json, then app folder will use react-hook-form at the parent directory. (However, vite might ignore the updates, need to configure vite)

Questions:

  • Why do we need to link react package as well? cc: @bluebill1049

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 4, 2022

@bluebill1049

  • Good news: Rollup and Test works! 🎉
  • In progress:
    • start script
    • compressed-size

@bluebill1049
Copy link
Member

Why do we need to link react package as well? cc: @bluebill1049

It was due to multiple react version issue, maybe it's no longer an issue.

@bluebill1049
Copy link
Member

@bluebill1049

  • Good news: Rollup and Test works! 🎉

  • In progress:

    • start script
    • compressed-size

That's awesome!

@bluebill1049
Copy link
Member

bluebill1049 commented Dec 4, 2022

I think it's no longer an issue with react version:

the following works

yarn build:esm && yarn --cwd ./app link react react-hook-form && yarn --cwd ./app run dev

I think this is the best option: (It's fine without the updates too)

  • Define "react-hook-form": "file:..", in app/package.json, then app folder will use react-hook-form at the parent directory. (However, vite might ignore the updates, need to configure vite)

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 5, 2022

Not sure why there are some cypress tests fail.
cc@bluebill1049
cypress fails

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 5, 2022

FYI: just added build:watch for rollup to rebuild when file changes

@bluebill1049
Copy link
Member

thanks @nvh95 I will fix those cypress tests.

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 5, 2022

@bluebill1049 The cypress tests just passed after I rebased on master. I am not sure if your latest commit fixes it, or they are unstable tests. I will keep my eyes on them as well.
Thank you, Bill.

@bluebill1049
Copy link
Member

I see, that's awesome! Thanks a lot @nvh95

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 5, 2022

@bluebill1049 If by any chance when you got some time, can you help to look at this failed action?
I guess the issue is with the use of pnpm and yarn when we try to do the comparison.
Thanks.

https://github.com/react-hook-form/react-hook-form/actions/runs/3615848030/jobs/6093262592

@bluebill1049
Copy link
Member

@nvh95 sure will do.

@bluebill1049
Copy link
Member

looks like it's determined by the.lock file: https://github.com/preactjs/compressed-size-action/blob/master/src/index.js#L59-L67

@bluebill1049
Copy link
Member

bluebill1049 commented Dec 5, 2022

on it's pulling the master, let's merge it in. It should just work.

it's try to pull the master to compare the size difference, hence it's not going to work out (yarn vs pnpm)

@bluebill1049 bluebill1049 marked this pull request as ready for review December 5, 2022 01:47
@nvh95
Copy link
Contributor Author

nvh95 commented Dec 5, 2022

@bluebill1049 I'm checking all the boxes in the PR description. I will let you know when it's done and we are good to merge

@bluebill1049
Copy link
Member

@bluebill1049 I'm checking all the boxes in the PR description. I will let you know when it's done and we are good to merge

Awesome! thanks so much for this @nvh95 🙏 🥳

@@ -2,7 +2,7 @@
"name": "react-hook-form",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"dev": "vite --force",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bluebill1049 --force is to invalidate the pre-bundle dependencies. This is a workaround. When you make changes to RHF, please restart the dev server of app.
We will try to improve this behavior to have real HMR. (See my comment in app/vite.config.ts for more)

Copy link
Member

Choose a reason for hiding this comment

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

Yea, no worries on that.

Comment on lines +10 to +11
# Do we want to run with multiple versions of node?
node-version: [16]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bluebill1049 It is recommended to specify which node version we use. FYI

Copy link
Member

Choose a reason for hiding this comment

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

sounds good 👍

Comment on lines +8 to +11
strategy:
matrix:
# Do we want to run with multiple versions of node?
node-version: [16]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bluebill1049 It is recommended to specify which node version we use. Also, we can test RHF on multiple node versions as well. For now, I just fixed it to node 16, we can change to following in the future if it's needed

Suggested change
strategy:
matrix:
# Do we want to run with multiple versions of node?
node-version: [16]
strategy:
matrix:
# Do we want to run with multiple versions of node?
node-version: [16, 18]

Copy link
Member

Choose a reason for hiding this comment

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

yep, 👍

- name: Test
run: |
yarn test --ci
yarn test:type
pnpm run test --ci
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pnpm test --ci fails,
pnpm run test --ci passed
Not have much time to check more details.
cc: @bluebill1049

Copy link
Member

Choose a reason for hiding this comment

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

haha that's strange, yea pnpm run test --ci is fine.

@nvh95
Copy link
Contributor Author

nvh95 commented Dec 5, 2022

@bluebill1049
I tried to check all the scripts. These scripts fail, I think I need your help:

  • coverage
  • test:native

For script e2e, GitHub Actions seems fine. But when I run it locally, this test suite fails (setValueAsyncStrictMode.cy.ts ). Please help to double check.
image

Otherwise, my PR is ready to be merged 🥳. Please help to do some testing from your side.

Thank you very much for this awesome library.

@bluebill1049
Copy link
Member

I will take over and resolve the rest 🌷 thanks @nvh95 a lot 👍

- coverage
- test:native
- test:server
Copy link
Member

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

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

🚀 This is really awesome and thanks very much for the huge effort!

@bluebill1049 bluebill1049 merged commit c7210f1 into react-hook-form:master Dec 5, 2022
@nvh95 nvh95 deleted the pnpm branch December 5, 2022 04:04
@@ -13,7 +13,7 @@
"joi": "^17.5.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-hook-form": "^7.25.0",
"react-hook-form": "file:..",

Choose a reason for hiding this comment

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

@nvh95 Hi, I have question why you don't use workspace:* keyword here?

Choose a reason for hiding this comment

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

aha still no pnpm-workspace.yaml file on project root,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @sadeghbarati. I considered that option #9516 (comment)

However, now, I am looking for the simplest solution, since this PR focuses on migrating to pnpm. In the next PR, I will adopt pnpm Workspace and use workspace:*.

Thanks for your suggestion 🤗.

Choose a reason for hiding this comment

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

Just saw your Tweet, Thanks for your efforts

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.

None yet

3 participants