Trying to make my plugin work as npm package with bun
Hello everyone, I built a better-auth plugin. It works perfectly when I use it directly in my app. But it doesn't work when I try to put it as an npm package. I tried to bun link it with
and copied the way @better-auth/stripe handles it.
But it still gives me this error:
Module not found: Can't resolve 'my-plugin'
1 | import { betterAuth} from "better-auth";
2 | import { myPlugin } from "my-plugin";| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Module not found: Can't resolve 'my-plugin/client' 1 | import { createAuthClient } from "better-auth/react";
2 | import { myPluginClient} from "my-plugin/client";| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8 Replies
Here is my configuration:
package.json:
tsconfig.json
build.config.ts
My folder structure
./root
--/src
---/my-plugin.ts
---/client.ts
---/index.ts
---/other-files....
I also tried to release it as an actual npm package not just a link but still not working
what doest your plugin do?
extend organization plugin with more functionality
It might be due to wrong module names, missing packages, or Bun not resolving modules properly.
I'll try using npm and pnpm and see what happens..
It's still not working....
It somtimes gives this error

Other times it gives this (This only shows in IDE)

When I try to run
It always gives me this error:
Cannot find module 'extended-organization/client' or its corresponding type declarations.ts(2307)
Probably the problem from link: functionality in my device.
I published the package to npm & everything is working perfectly.
Note: I had to add .npmignore file & exclude everything that is in .gitignore EXCEPT dist folder