file-type icon indicating copy to clipboard operation
file-type copied to clipboard

Can't access node functions when tsconfig moduleResolution is set to "bundler"

Open alex-e-leon opened this issue 6 months ago • 5 comments

I'm using tsup to bundle my node project into a single file, and have moduleResolution: "bundler" set in my tsconfig because a) it feels like the right choice as I'm using a bundler, and b) it allows me to ignore writing out file type extensions with esm.

Unfortunately it looks like file-type only exposes node functions like fileTypeFromFile when moduleResolution is set to "node". I get that this is done to add extra safety and prevent consumers from importing functions that don't work in the environment that they are running, and 99% of projects with moduleResolution: "bundler" are likely headed for the browser, but considering that bundling is valid for node projects as well, I wonder whether the exports should be relaxed for this?

alex-e-leon avatar Aug 08 '24 00:08 alex-e-leon