nksaraf / vinxi

The Full Stack JavaScript SDK
https://vinxi.vercel.app
MIT License
2.22k stars 80 forks source link

Vinxi is treeshaking tslib modules needed for bun #402

Open atoko opened 1 month ago

atoko commented 1 month ago

Looks like vinxi build is not bundling the tslib/modules folder when used with Tanstack Start.

This causes bun to not be able to start the server since it "can't find" tslib. Copying over a non-tree shaked tslib into .output/node_module fixes the issue.

Example error:

ERROR error: Cannot find package "tslib" from "/var/task/app/.output/server/index.mjs"
--
KATT commented 2 days ago

I got this error too whilst trying to add tslib as a dependency to trpc (https://github.com/trpc/trpc/pull/6271) (using Node, not Bun).

We have a lot of example projects in tRPC where we do build & e2e tests. TanStack Start is one of them and the only one failing.

Manually patching node_modules/tslib/package.json with the below makes it pass, that's not really a solution but might give a clue to someone who understands this better than I do

     "exports": {
         ".": {
             "module": {
                 "types": "./modules/index.d.ts",
                 "default": "./tslib.es6.mjs"
             },
             "import": {
-                "node": "./modules/index.js",
-                "default": {
-                    "types": "./modules/index.d.ts",
-                    "default": "./tslib.es6.mjs"
-                }
+                "types": "./modules/index.d.ts",
+                "default": "./tslib.es6.mjs"
             },
             "default": "./tslib.js"
         },
-        "./*": "./*",
-        "./": "./"
+        "./*": "./*"
     }