junhoyeo / threads-api

Unofficial, Reverse-Engineered Node.js/TypeScript client for Meta's Threads. Web UI Included.
https://threads.junho.io
MIT License
1.58k stars 134 forks source link

Bun Support #206

Open sooluh opened 11 months ago

sooluh commented 11 months ago

You already know that I created @fitrahive/oneayah-threads with @oven-sh/bun, and I didn't use the threads-api as a dependency. Instead, I used a git submodule. This is because when I tried to use it as a dependency, I encountered the following error:

warn: Invalid original column value
/path/oneayah-threads/node_modules/threads-api/build/threads-api.js:1:0 16158[userID] Failed to fetch userID, Fallbacking to login 2439 |           `Adapter ${nameOrAdapter} is not supported by the environment`,
2440 |           'ERR_NOT_SUPPORT'
2441 |         );
2442 |       }
2443 |
2444 |       throw new Error(
                ^
error: Adapter 'http' is not available in the build
      at getAdapter (/path/oneayah-threads/node_modules/axios/dist/browser/axios.cjs:2444:12)
      at dispatchRequest (/path/oneayah-threads/node_modules/axios/dist/browser/axios.cjs:2499:18)
      at request (/path/oneayah-threads/node_modules/axios/dist/browser/axios.cjs:2859:16)
      at /path/oneayah-threads/node_modules/axios/dist/browser/axios.cjs:2885:11
      at wrap (/path/oneayah-threads/node_modules/axios/dist/browser/axios.cjs:6:11)
      at /path/oneayah-threads/node_modules/threads-api/build/threads-api.js:254:25
      at /path/oneayah-threads/node_modules/threads-api/build/threads-api.js:116:18
      at /path/oneayah-threads/node_modules/threads-api/build/threads-api.js:125:9
      at i (/path/oneayah-threads/node_modules/threads-api/build/threads-api.js:10:14)
      at o (/path/oneayah-threads/node_modules/threads-api/build/threads-api.js:23:10)

And I tried using the submodule, and it worked because I think Bun handles TypeScript well. However, when I added it as a dependency, the runtime started using the built result, which not all runtimes could execute (I'm not sure if this is understandable or not).

But if we look at the error, it's a problem with axios. I tried searching and found this tweet. Yes, axios has been supported by Bun for a few months now (reference here).

But if the issue is with axios, why does it work fine when using the submodule but not when using it as a dependency (built result)? I think this might be due to the build configuration, but I'm not sure.