jotaijs / jotai-devtools

A powerful toolkit to enhance your development experience with Jotai
https://jotai.org/docs/tools/devtools
MIT License
124 stars 29 forks source link

jotai-devtools not working with PNPM (declare jotai as a dependency) #122

Closed bheberer closed 6 months ago

bheberer commented 6 months ago

https://github.com/jotaijs/jotai-devtools/blob/9db195108ce82fa44f3dd72b0515d8a94d480048/package.json#L140C6-L140C11

Some context. I'm working in a bazel + PNPM app and I created a package that includes both jotai and jotai-devtools as regular dependencies.

When I try to use that package in my app, I was getting the following error:

Module not found: Error: Can't resolve 'jotai/react' in '/private/var/tmp/_bazel_william.heberer/5267ba2fd8a6fbaf9ba9f8f7d732ebcd/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/jotai-devtools@0.7.1_1687856300/node_modules/jotai-devtools/dist'
resolve 'jotai/react' in '/private/var/tmp/_bazel_william.heberer/5267ba2fd8a6fbaf9ba9f8f7d732ebcd/execroot/rh/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/jotai-devtools@0.7.1_1687856300/node_modules/jotai-devtools/dist'

Seems to be an issue w/ how PNPM handles module resolution. It expects jotai to be included as a regular dependency rather than a devDependency. Would there be any downside to moving jotai over to a regular dependency? We were forced to use a PNPM package extension to work around this:

// package.json
"pnpm": {
    "packageExtensions": {
      "jotai-devtools": {
        "dependencies": {
          "jotai": "*"
        }
      }
    }
arjunvegda commented 6 months ago

Thanks for reaching out!

Based on your description, this seems like a bug on Bazel or PNPM (when used with Bazel).

We wouldn't want to include jotai in the dependency of this package as it's not tied to a specific version of it. This package uses whichever version of jotai the user has on their project.

Also * means using any version of Jotai, which could result in issues down the line from a library perspective.

I tried reproducing this locally using pnpm without Bazel, and it works fine for me. Could you file a request with Bazel/PNPM?

arjunvegda commented 6 months ago

Closing this issue as it's not related to jotai-devtools. Please feel free to re-open it if needed.