Skip to content

exports incompatible with TypeScript "moduleResolution": "node16" #29

@jridgewell

Description

@jridgewell

Originally reported by @HereIsKevin at ampproject/remapping#194

Because the type declarations are .d.ts and the package does not have "type": "module", TypeScript assumes this package is CommonJS only despite having an ESM export when "moduleResolution": "node16" is used.

A potential fix could be changing exports include the following and creating a remapping.d.mts file identical to remapping.d.ts. This causes TypeScript to resolve to remapping.d.mts for ESM first and fallback to remapping.d.ts otherwise. This should not impact any build tools.

{
  "import": {
    "types": "./dist/types/remapping.d.mts",
    "default": "./dist/remapping.mjs"
  },
  "types": "./dist/types/remapping.d.ts",
  "browser": "./dist/remapping.umd.js",
  "require": "./dist/remapping.umd.js"
}

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