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(types): useAtom with one type argument for primitive atoms #2386

Merged
merged 6 commits into from
Feb 21, 2024

Conversation

dai-shi
Copy link
Member

@dai-shi dai-shi commented Feb 9, 2024

This has been asked several times. Hope this doesn't break some usages.

Copy link

vercel bot commented Feb 9, 2024

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 Feb 12, 2024 1:18am

Copy link

codesandbox-ci bot commented Feb 9, 2024

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 f0cb490:

Sandbox Source
React Configuration
React TypeScript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration

Copy link

github-actions bot commented Feb 9, 2024

Size Change: 0 B

Total Size: 70.8 kB

ℹ️ View Unchanged
Filename Size
dist/babel/plugin-debug-label.js 907 B
dist/babel/plugin-react-refresh.js 1.14 kB
dist/babel/preset.js 1.38 kB
dist/index.js 242 B
dist/react.js 1.06 kB
dist/react/utils.js 1.26 kB
dist/system/babel/plugin-debug-label.development.js 1.09 kB
dist/system/babel/plugin-debug-label.production.js 757 B
dist/system/babel/plugin-react-refresh.development.js 1.29 kB
dist/system/babel/plugin-react-refresh.production.js 929 B
dist/system/babel/preset.development.js 1.56 kB
dist/system/babel/preset.production.js 1.13 kB
dist/system/index.development.js 253 B
dist/system/index.production.js 182 B
dist/system/react.development.js 1.18 kB
dist/system/react.production.js 711 B
dist/system/react/utils.development.js 722 B
dist/system/react/utils.production.js 461 B
dist/system/utils.development.js 258 B
dist/system/utils.production.js 188 B
dist/system/vanilla.development.js 4.16 kB
dist/system/vanilla.production.js 2.09 kB
dist/system/vanilla/utils.development.js 4.73 kB
dist/system/vanilla/utils.production.js 2.88 kB
dist/umd/babel/plugin-debug-label.development.js 1.06 kB
dist/umd/babel/plugin-debug-label.production.js 845 B
dist/umd/babel/plugin-react-refresh.development.js 1.28 kB
dist/umd/babel/plugin-react-refresh.production.js 1.01 kB
dist/umd/babel/preset.development.js 1.53 kB
dist/umd/babel/preset.production.js 1.24 kB
dist/umd/index.development.js 381 B
dist/umd/index.production.js 329 B
dist/umd/react.development.js 1.18 kB
dist/umd/react.production.js 785 B
dist/umd/react/utils.development.js 1.43 kB
dist/umd/react/utils.production.js 1.03 kB
dist/umd/utils.development.js 398 B
dist/umd/utils.production.js 343 B
dist/umd/vanilla.development.js 4.96 kB
dist/umd/vanilla.production.js 2.68 kB
dist/umd/vanilla/utils.development.js 5.64 kB
dist/umd/vanilla/utils.production.js 3.47 kB
dist/utils.js 246 B
dist/vanilla.js 4.88 kB
dist/vanilla/utils.js 5.5 kB

compressed-size-action

Copy link

github-actions bot commented Feb 9, 2024

LiveCodes Preview in LiveCodes

Latest commit: f0cb490
Last updated: Feb 12, 2024 1:17am (UTC)

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

See documentations for usage instructions.

@dai-shi
Copy link
Member Author

dai-shi commented Feb 9, 2024

LiveCodes Preview in LiveCodes

Latest commit: 02f4f47 Last updated: Feb 9, 2024 12:36pm (UTC)

Playground Link
React demo https://livecodes.io?x=id/7DSD5EUVS
See documentations for usage instructions.

@hatemhosny Unfortunately, it causes an error.

image

Empty imports?

image

@hatemhosny
Copy link

It seems Jotai is not being bundled.

The GitHub action will not bundle the files, it can just make them available as data urls.

The import map was indeed loaded. You can view project json: app menu -> export -> export project (json)

It looks like this:

{
...
"imports": {
    "jotai": "data:application/javascript;charset=UTF-8;base64,ZXhwb3J0ICogZnJvbSAnam90YWkvdmFuaWxsYSc7CmV4cG9ydCAqIGZyb20gJ2pvdGFpL3JlYWN0JzsK"
  },
...
}

The data url is loaded like that:

export * from 'jotai/vanilla';
export * from 'jotai/react';

Which gives the error message.

You can either:

  • bundle the files (in the build-command input) and load the bundle
  • add all the used files in the imports as data urls
  • deploy the files to a preview environment and use {{LC::TO_URL(./file.js)}} pattern, then relative imports can work

If you want the import map to appear in UI (custom settings) put the imports property inside customSettings property, like this:

{
  ...
  "customSettings": {
    "imports": {
      "jotai": "..."
    }
  },
  ...
}

@dai-shi
Copy link
Member Author

dai-shi commented Feb 10, 2024

@hatemhosny
Thanks.
Yes, we need to build it.

If you want the import map to appear in UI

No, I don't need that.

@dai-shi
Copy link
Member Author

dai-shi commented Feb 10, 2024

#2387

@dai-shi
Copy link
Member Author

dai-shi commented Feb 10, 2024

#2388

@dai-shi
Copy link
Member Author

dai-shi commented Feb 10, 2024

LiveCodes Preview in LiveCodes

Latest commit: 87637f2 Last updated: Feb 10, 2024 1:04am (UTC)

Playground Link
React demo https://livecodes.io?x=id/GA8SB847X
See documentations for usage instructions.

Works now! 🎉

@dai-shi
Copy link
Member Author

dai-shi commented Feb 10, 2024

I wonder if the action works from forked repo, though. Will see.

@hatemhosny
Copy link

Works now! 🎉

Very nice 🎉

I wonder if the action works from forked repo, though. Will see.

I will do a test PR to demonstrate that from an account with no permissions on your repo.

@hatemhosny hatemhosny mentioned this pull request Feb 10, 2024
@hatemhosny
Copy link

I wonder if the action works from forked repo, though. Will see.

I will do a test PR to demonstrate that from an account with no permissions on your repo.

It works :)
#2389 (comment)

@dai-shi dai-shi added this to the v2.6.5 milestone Feb 10, 2024
@dai-shi
Copy link
Member Author

dai-shi commented Feb 11, 2024

If you want the import map to appear in UI

No, I don't need that.

@hatemhosny
Actually, we need to know which commit is used in the UI, and it would be nice if we can revert it back to the npm version.
So, we should make it appear in UI.

@dai-shi dai-shi mentioned this pull request Feb 11, 2024
@dai-shi dai-shi merged commit a9eeadb into main Feb 21, 2024
34 checks passed
@dai-shi dai-shi deleted the improve-use-atom-typing branch February 21, 2024 14:23
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