← All tasks
javascriptsindresorhus/file-type #652Not a task: already works

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

envgap__sindresorhus__file-type-652

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
37ea058a7f23c4aa3426658a2e71f266cfb4ea3c
Manifest
package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

sindresorhus/file-type #652 · read the original issue
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?
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]