lukeed / typescript-module

Template repository for authoring npm modules via TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add conditional exports

dandv opened this issue · comments

Thanks for this template! The only issue I've run into while using it was that I couldn't use name imports from transpiled ESM code ("module": "esnext" in tsconfig.json). The error (seen by others in similar situations) was,

The requested module '...' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.

I've solved that in my package local-iso-dt by using conditional exports (diff).

Added, thank you for the reminder :) I think I was still on-the-fence about the exports landscape, but I think enough time has passed to make me feel like it's safe to just provide it as a default.