-
Notifications
You must be signed in to change notification settings - Fork 33
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
0.6.0 broke Vite dev mode #82
Comments
Maybe polyfilling the process node module can help, I will try. Not sure if other bundlers will have similar problems. |
vite-plugin-node-polyfills helped |
also running into this issue. by sheer coincidence, last week we needed to build json diff/patching into our project. we ran into issues with jsondiffpatch for exactly this reason, and instead moved to fast-json-patch, which is a much cleaner and more modern API. it's typescript-native. might be worth considering! |
Thanks for reaching out and for the investigation! It's super helpful I'm currently away from keyboard for a week, I'll look into this in detail sometime next week. Meanwhile, is this happening only with Vite? Or are we seeing issues with Rollup and other bundlers too? |
This issue is logged on their repo too. There are a few workarounds you may look into btw.
Thanks for the recommendation. |
Ah sorry, for the lack of a contribution guide 😅. We use storybook to develop this extension. Here are steps to get you up and running locally
|
so, i did a bit more digging here. tl;dr i don't think we should use I've created a PR #85 which implements this patch using pnpm. I can confirm that my patch at least prevents jotai-devtools from from totally breaking vite, but I can't actually test the functionality because I still get that issue where all the atoms are missing when I install via More context: Besides that, looking at the code, it's very tightly coupled to the diff format produced by Given that... I think the best option is simply using |
Thanks for your investigation and PR! I'm not very confident in shipping a patch via Perhaps, you may be interested in creating a PR in the jsondiffpatch repo for this issue 😄
We have a canary deployment setup for PRs, here are the instructions on how to install the canary version generated using your PR. |
agreed with you! the pnpm patching system was new to me too — i tried the canary package and it fails with the same chalk/process issue, so looks like the pnpm patch isn't coming through. I do feel that this is something that should be fixed in jotai-devtools, or at the very least documented, since ultimately jotai-devtools is bundling a dependency with a show-stopping bug in it for vite users. i agree that the ideal outcome is jsondiffpatch fixes this, but it seems that package has been abandoned since 2021, so I think a PR will fall on deaf ears :( |
Yes, ideally it'd be nice to address it in
The author of the Chalk dropped the |
I tried this! Unfortunately, the build fails due to some import error. I created a PR that should fix this on the jsondiffpatch repo 🤞 |
Writing here to say that I also am experiencing this issue. I really hope that PR for jsondiffpatch goes through and is a solution to this. Would really love to use the DevTools soon! My project's setup is
|
Hey @maylortaylor, just to clarify further, this issue does not completely block you from using DevTools. DevTools does not rely on the code that's causing this error 😁 Here is a workaround you may use in your project. Define export default defineConfig({
// ...
define: {
'process.platform': '' // you may set this to anything
}
}) |
Thanks so much @arjunvegda! I set I would also suggest adding a new prop on the Devtools that would set it's placement (top-right, bottom-left, etc) |
Great suggestions! @maylortaylor. Let's continue this discussion in #86 |
I choose to use version 0.5.3 |
Just an fyi, this doesn't work with Vitest because then Vitest can't set Edit: There's actually an even better way to do this, which is overriding packages. Add the following in your "overrides": {
"jotai-devtools": {
"chalk": "^4.1.2"
}
} Yarn: "resolutions": {
"jotai-devtools/**/chalk": "^4.1.2"
} PNPM: "pnpm": {
"overrides": {
"jotai-devtools>chalk": "^4.1.2"
}
} Note: I've only tested with NPM. |
@Xenfo Thanks for sharing your solution! 🙏 Out of curiosity, why do we need Jotai DevTools when running tests? 🤔 |
We don't but the |
Wouldn't it be safer to wrap |
this worked a charm! for me, using pnpm, what I had to do was: "pnpm": {
"overrides": {
"jsondiffpatch>chalk": "^4.1.2"
}
} |
Jotai Devtools isn't part of any test code but the define block applies to all environments (including Vitest). export default defineConfig({
// ...
define: {
'process.platform': '' // you may set this to anything
}
}) This define block will make |
Fix released in |
If i update jotai-devtools to 0.6.0 my UI breaks with the following message in the console:
Chalk is an npm package which works only in a Node environment, hence process is not defined.
If I look at the stacktrace, the error comes from this origin:
Time travel is a new feature in devtools 0.6 if I understand correctly.
Could it be that some of the imported npm packages there use chalk internally? Maybe @mantine/core?
The text was updated successfully, but these errors were encountered: