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

fix(shallow): Extract shallow vanilla and react #2097

Merged
merged 19 commits into from
Oct 5, 2023

Conversation

dbritto-dev
Copy link
Collaborator

@dbritto-dev dbritto-dev commented Oct 3, 2023

Related Issues or Discussions

Fix #2095

Summary

  • Split shallow in two modules: zustand/shallow and zustand/shallow/react
  • Split tests for vanilla and react

Check List

  • yarn run prettier for formatting code and docs

@vercel
Copy link

vercel bot commented Oct 3, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
zustand-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 4, 2023 11:46pm

@dbritto-dev dbritto-dev self-assigned this Oct 3, 2023
@dbritto-dev dbritto-dev added the enhancement New feature or request label Oct 3, 2023
@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 3, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 223c67f:

Sandbox Source
React Configuration
React TypeScript Configuration
React Browserify Configuration
React Snowpack Configuration
React Parcel Configuration
Next.js Configuration
@pavlobu/zustand demo Configuration

@dbritto-dev dbritto-dev changed the title Extract shallow vanilla Extract shallow vanilla and react Oct 3, 2023
@dbritto-dev
Copy link
Collaborator Author

@dai-shi here you go

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

tests/vanilla/shadow.test.tsx -> tests/vanilla/shallow.test.tsx ?
(Not sure if I prefer the folder structure under tests, but I know what you want.)

We also need to change package.json. Please create ./shallow/react entry point. (see how ./middleware/immer is defined.

@dbritto-dev
Copy link
Collaborator Author

dbritto-dev commented Oct 4, 2023

tests/vanilla/shadow.test.tsx -> tests/vanilla/shallow.test.tsx ? (Not sure if I prefer the folder structure under tests, but I know what you want.)

We also need to change package.json. Please create ./shallow/react entry point. (see how ./middleware/immer is defined.

@dai-shi about folder structure under tests I'm following the structure on jotai tests

@dbritto-dev
Copy link
Collaborator Author

@dai-shi all yours, keep me in the loop

@dai-shi
Copy link
Member

dai-shi commented Oct 4, 2023

about folder structure under tests I'm following the structure on jotai tests

wait, I think I misunderstood the jotai structure for "src" too.
if we were to follow it, it will be:

  • zustand/shallow
  • zustand/vanilla/shallow
  • zustand/react/shallow

What do you think?

@dbritto-dev
Copy link
Collaborator Author

@dai-shi sounds good to me let me update it to match the src structure too

@dbritto-dev
Copy link
Collaborator Author

@dai-shi all yours

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

Thanks for the revision. Looks good overall. See the comments.

src/vanilla/shallow.ts Outdated Show resolved Hide resolved
src/shallow.ts Outdated Show resolved Hide resolved
Co-authored-by: Daishi Kato <dai-shi@users.noreply.github.com>
@dbritto-dev
Copy link
Collaborator Author

@dai-shi all yours, keep me in the loop

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

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

The code looks good.
Can you try creating a codesandbox example? It should fail.
We need to add two build scripts like this:

"build:vanilla:shallow": "rollup -c --config-vanilla_shallow",
"build:react:shallow": "rollup -c --config-react_shallow",

and the codesandbox example should work.

@dbritto-dev
Copy link
Collaborator Author

@dai-shi locally works, let's ship it haha :D I'm just joking

@dai-shi
Copy link
Member

dai-shi commented Oct 5, 2023

@dai-shi dai-shi added this to the v4.4.3 milestone Oct 5, 2023
@dai-shi dai-shi changed the title Extract shallow vanilla and react fix(shallow): Extract shallow vanilla and react Oct 5, 2023
@dai-shi dai-shi merged commit e414f7c into pmndrs:main Oct 5, 2023
35 checks passed
@dbritto-dev dbritto-dev deleted the extract-shallow-vanilla branch October 5, 2023 15:08
bodinsamuel pushed a commit to specfy/specfy that referenced this pull request Nov 8, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [zustand](https://togithub.com/pmndrs/zustand) | [`4.4.1` ->
`4.4.6`](https://renovatebot.com/diffs/npm/zustand/4.4.1/4.4.6) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/zustand/4.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/zustand/4.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/zustand/4.4.1/4.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/zustand/4.4.1/4.4.6?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>pmndrs/zustand (zustand)</summary>

### [`v4.4.6`](https://togithub.com/pmndrs/zustand/releases/tag/v4.4.6)

[Compare
Source](https://togithub.com/pmndrs/zustand/compare/v4.4.5...v4.4.6)

v4.4.5 has an issue with some TypeScript configs about module
resolution. It should be fixed now. Thanks for the patience.

#### What's Changed

- Update export types by
[@&#8203;dbritto-dev](https://togithub.com/dbritto-dev) in
[pmndrs/zustand#2170

#### New Contributors

- [@&#8203;cheatkey](https://togithub.com/cheatkey) made their first
contribution in
[pmndrs/zustand#2147
- [@&#8203;frixaco](https://togithub.com/frixaco) made their first
contribution in
[pmndrs/zustand#2166

**Full Changelog**:
pmndrs/zustand@v4.4.5...v4.4.6

### [`v4.4.5`](https://togithub.com/pmndrs/zustand/releases/tag/v4.4.5)

[Compare
Source](https://togithub.com/pmndrs/zustand/compare/v4.4.4...v4.4.5)

Hopefully, it should fix some issues with Node.js environment including
Next.js.

#### What's Changed

- fix: importing CJS React in ESM by
[@&#8203;dai-shi](https://togithub.com/dai-shi) in
[pmndrs/zustand#2154
- Apply publint recommendations by
[@&#8203;dbritto-dev](https://togithub.com/dbritto-dev) in
[pmndrs/zustand#2157

#### New Contributors

- [@&#8203;plrs9816](https://togithub.com/plrs9816) made their first
contribution in
[pmndrs/zustand#2137
- [@&#8203;Brammm](https://togithub.com/Brammm) made their first
contribution in
[pmndrs/zustand#2139
- [@&#8203;sobies93](https://togithub.com/sobies93) made their first
contribution in
[pmndrs/zustand#2142

**Full Changelog**:
pmndrs/zustand@v4.4.4...v4.4.5

### [`v4.4.4`](https://togithub.com/pmndrs/zustand/releases/tag/v4.4.4)

[Compare
Source](https://togithub.com/pmndrs/zustand/compare/v4.4.3...v4.4.4)

There was a tiny issue in v4.4.3, which broke with some bundlers, which
this version fixes.

#### What's Changed

- fix(build): patch entry points zustand/shallow for CJS by
[@&#8203;dai-shi](https://togithub.com/dai-shi) in
[pmndrs/zustand#2128

**Full Changelog**:
pmndrs/zustand@v4.4.3...v4.4.4

### [`v4.4.3`](https://togithub.com/pmndrs/zustand/releases/tag/v4.4.3)

[Compare
Source](https://togithub.com/pmndrs/zustand/compare/v4.4.2...v4.4.3)

The changes in v4.4.2 were troublesome for some users. This version
should fix/mitigate such cases.

#### What's Changed

- fix(shallow): Extract shallow vanilla and react by
[@&#8203;dbritto-dev](https://togithub.com/dbritto-dev) in
[pmndrs/zustand#2097
- fix(types): mitigate devtools typing by
[@&#8203;dai-shi](https://togithub.com/dai-shi) in
[pmndrs/zustand#2099

**Full Changelog**:
pmndrs/zustand@v4.4.2...v4.4.3

### [`v4.4.2`](https://togithub.com/pmndrs/zustand/releases/tag/v4.4.2)

[Compare
Source](https://togithub.com/pmndrs/zustand/compare/v4.4.1...v4.4.2)

This adds `useShallow` hook to cover some use cases that are deprecated
with v4.4.0 change. Check out [the
guide](https://togithub.com/pmndrs/zustand/blob/ec538e9d4c0b9b5759e6dfd0fd3c9a21f8236949/docs/guides/prevent-rerenders-with-use-shallow.md).

##### Migration Guide

[#&#8203;1991](https://togithub.com/pmndrs/zustand/issues/1991) requires
something like below if you are using the `devtools` middleware *and*
TypeScript.

```diff
  import { devtools } from 'zustand/middleware'
+ import type {} from '@&#8203;redux-devtools/extension'
```

##### What's Changed

- fix(types)(middleware/devtools): avoid copying types by
[@&#8203;dai-shi](https://togithub.com/dai-shi) in
[pmndrs/zustand#1991
- fix(traditional): make defaultEqualityFn optional in TS Types by
[@&#8203;charkour](https://togithub.com/charkour) in
[pmndrs/zustand#2060
- feat: add useShallow by
[@&#8203;FaberVitale](https://togithub.com/FaberVitale) in
[pmndrs/zustand#2090

##### New Contributors

- [@&#8203;aykutkardas](https://togithub.com/aykutkardas) made their
first contribution in
[pmndrs/zustand#1993
- [@&#8203;michelts](https://togithub.com/michelts) made their first
contribution in
[pmndrs/zustand#1997
- [@&#8203;elusive](https://togithub.com/elusive) made their first
contribution in
[pmndrs/zustand#2001
- [@&#8203;mayank1513](https://togithub.com/mayank1513) made their first
contribution in
[pmndrs/zustand#2015
- [@&#8203;fdb](https://togithub.com/fdb) made their first contribution
in
[pmndrs/zustand#2029
- [@&#8203;tmkx](https://togithub.com/tmkx) made their first
contribution in
[pmndrs/zustand#2032
- [@&#8203;OshriAsulin](https://togithub.com/OshriAsulin) made their
first contribution in
[pmndrs/zustand#2028
- [@&#8203;ivanquirino](https://togithub.com/ivanquirino) made their
first contribution in
[pmndrs/zustand#2047
- [@&#8203;stavkamil](https://togithub.com/stavkamil) made their first
contribution in
[pmndrs/zustand#2071
- [@&#8203;NaamuKim](https://togithub.com/NaamuKim) made their first
contribution in
[pmndrs/zustand#2088
- [@&#8203;FaberVitale](https://togithub.com/FaberVitale) made their
first contribution in
[pmndrs/zustand#2090

**Full Changelog**:
pmndrs/zustand@v4.4.1...v4.4.2

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "after 4pm every weekday" in timezone
Europe/Paris, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/specfy/specfy).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40Ni4wIiwidXBkYXRlZEluVmVyIjoiMzcuNDYuMCIsInRhcmdldEJyYW5jaCI6ImNob3JlL3Jlbm92YXRlQmFzZUJyYW5jaCJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants