Skip to content

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

@alex-e-leon

Description

@alex-e-leon

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions