Skip to content

Conversation

@fisker
Copy link

@fisker fisker commented Mar 20, 2025

The "types" condition should always come first in "exports"

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-7.html#:~:text=The%20%22types%22%20condition%20should%20always%20come%20first%20in%20%22exports%22.

This condition should always be included first

https://nodejs.org/api/packages.html#:~:text=This%20condition%20should%20always%20be%20included%20first.

When bundle this package with esbuild, it also emits a warning

$ echo import "lines-and-columns" | npx esbuild --log-level=debug --bundle

● [DEBUG] The condition "types" here will never be used as it comes after both "import" and "require" [package.json]

    node_modules/lines-and-columns/package.json:25:4:
      25 │     "types": "./build/index.d.ts"
         ╵     ~~~~~~~

  The "import" condition comes earlier and will be used for all "import" statements:

    node_modules/lines-and-columns/package.json:23:4:
      23 │     "import": "./build/index.mjs",
         ╵     ~~~~~~~~

  The "require" condition comes earlier and will be used for all "require" calls:

    node_modules/lines-and-columns/package.json:24:4:
      24 │     "require": "./build/index.cjs",
         ╵     ~~~~~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant