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(core/unstable): expose internals instead of unstable_derive #2911

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

dai-shi
Copy link
Member

@dai-shi dai-shi commented Jan 6, 2025

Following #2905, I think we could provide some internal functions because unstable_derive turns out to be somewhat limited.

Copy link

vercel bot commented Jan 6, 2025

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

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 7, 2025 10:45pm

Copy link

codesandbox-ci bot commented Jan 6, 2025

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.

Copy link

pkg-pr-new bot commented Jan 6, 2025

Open in Stackblitz

More templates

npm i https://pkg.pr.new/jotai@2911

commit: f130ff6

Copy link

github-actions bot commented Jan 6, 2025

Size Change: +953 B (+1.04%)

Total Size: 93 kB

Filename Size Change
./dist/esm/index.mjs 99 B +37 B (+59.68%) 🆘
./dist/esm/vanilla.mjs 4.27 kB +51 B (+1.21%)
./dist/index.js 280 B +38 B (+15.7%) ⚠️
./dist/system/index.development.js 298 B +46 B (+18.25%) ⚠️
./dist/system/index.production.js 224 B +41 B (+22.4%) 🚨
./dist/system/vanilla.development.js 4.39 kB +80 B (+1.85%)
./dist/system/vanilla.production.js 2.24 kB +69 B (+3.18%)
./dist/umd/index.development.js 425 B +42 B (+10.97%) ⚠️
./dist/umd/index.production.js 354 B +26 B (+7.93%) 🔍
./dist/umd/vanilla.development.js 5.86 kB +180 B (+3.17%)
./dist/umd/vanilla.production.js 3.02 kB +156 B (+5.46%) 🔍
./dist/vanilla.js 5.75 kB +187 B (+3.36%)
ℹ️ View Unchanged
Filename Size
./dist/babel/plugin-debug-label.js 932 B
./dist/babel/plugin-react-refresh.js 1.14 kB
./dist/babel/preset.js 1.41 kB
./dist/esm/babel/plugin-debug-label.mjs 1 kB
./dist/esm/babel/plugin-react-refresh.mjs 1.19 kB
./dist/esm/babel/preset.mjs 1.49 kB
./dist/esm/react.mjs 1.4 kB
./dist/esm/react/utils.mjs 746 B
./dist/esm/utils.mjs 67 B
./dist/esm/vanilla/utils.mjs 5.04 kB
./dist/react.js 1.44 kB
./dist/react/utils.js 1.39 kB
./dist/system/babel/plugin-debug-label.development.js 1.1 kB
./dist/system/babel/plugin-debug-label.production.js 775 B
./dist/system/babel/plugin-react-refresh.development.js 1.29 kB
./dist/system/babel/plugin-react-refresh.production.js 928 B
./dist/system/babel/preset.development.js 1.59 kB
./dist/system/babel/preset.production.js 1.14 kB
./dist/system/react.development.js 1.56 kB
./dist/system/react.production.js 864 B
./dist/system/react/utils.development.js 860 B
./dist/system/react/utils.production.js 462 B
./dist/system/utils.development.js 257 B
./dist/system/utils.production.js 187 B
./dist/system/vanilla/utils.development.js 5.25 kB
./dist/system/vanilla/utils.production.js 3.14 kB
./dist/umd/babel/plugin-debug-label.development.js 1.08 kB
./dist/umd/babel/plugin-debug-label.production.js 852 B
./dist/umd/babel/plugin-react-refresh.development.js 1.27 kB
./dist/umd/babel/plugin-react-refresh.production.js 1 kB
./dist/umd/babel/preset.development.js 1.54 kB
./dist/umd/babel/preset.production.js 1.22 kB
./dist/umd/react.development.js 1.57 kB
./dist/umd/react.production.js 936 B
./dist/umd/react/utils.development.js 1.53 kB
./dist/umd/react/utils.production.js 1.01 kB
./dist/umd/utils.development.js 399 B
./dist/umd/utils.production.js 342 B
./dist/umd/vanilla/utils.development.js 6.24 kB
./dist/umd/vanilla/utils.production.js 3.78 kB
./dist/utils.js 247 B
./dist/vanilla/utils.js 6.1 kB

compressed-size-action

Copy link

github-actions bot commented Jan 6, 2025

LiveCodes Preview in LiveCodes

Latest commit: f130ff6
Last updated: Jan 7, 2025 10:44pm (UTC)

Playground Link
React demo https://livecodes.io?x=id/2SX2UNF96

See documentations for usage instructions.

@dai-shi dai-shi changed the title Feat/core/expose internals instead of derive feat(core/unstable): expose internals instead of unstable_derive Jan 6, 2025
@dai-shi dai-shi marked this pull request as ready for review January 6, 2025 08:13
@dmaskasky
Copy link
Collaborator

Wow, this is incredibly powerful and flexible.

I appreciate that it doesn't allow direct mutation of an existing store's internal functions, yet provides all the necessary tools to build a new store if you know what you’re doing.

This might be overkill for jotai-scope, but it’s reassuring to have this flexibility available. My only concern is that exposing more of the API can be daunting to anyone who looks under the hood. It might be preferable to group these exports under a single INTERNAL_-prefixed object—or otherwise encapsulate them—to improve clarity and reduce the risk of overwhelming new users.

@dai-shi
Copy link
Member Author

dai-shi commented Jan 6, 2025

It might be preferable to group these exports under a single INTERNAL_-prefixed object

I don't like objects, as they are not minifyable. Let me try a namespace.

@dai-shi
Copy link
Member Author

dai-shi commented Jan 7, 2025

This actually doesn't work as current rollup config. Let me revert it.

I can do it again with a follow-up PR. (Can't do it in this PR as it conflicts too much.)

@dai-shi
Copy link
Member Author

dai-shi commented Jan 8, 2025

I think this should come with a new minor.

@dai-shi dai-shi marked this pull request as draft January 8, 2025 01:59
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