Update TypeScript exports to support moduleResolution bundler #9

Closed
opened 2023-09-02 16:04:15 +02:00 by kwangure · 1 comment
kwangure commented 2023-09-02 16:04:15 +02:00 (Migrated from github.com)

moduleResolution: "bundler" is a recent setting added to TypeScript to support bundler setups. It's the setting you should probably be using when bundling code. With this setting TypeScript only searches for types in the exports field of the package.json.

It requires the following change:

 "exports": {
   "import": "./dist/index.js",
   "require": "./dist/index.cjs",
+  "types": "./dist/index.d.ts"
 },
[`moduleResolution: "bundler"`](https://www.typescriptlang.org/tsconfig#moduleResolution) is a recent setting added to TypeScript to support bundler setups. It's the setting you should probably be using when bundling code. With this setting TypeScript only searches for types in the exports field of the `package.json`. It requires the following change: ```diff "exports": { "import": "./dist/index.js", "require": "./dist/index.cjs", + "types": "./dist/index.d.ts" }, ```
marijnh commented 2023-09-04 18:41:04 +02:00 (Migrated from github.com)

Should already work as of 426fe04281

Should already work as of 426fe0428187967a07597aa7f0dd00e9aec5e4fc
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/html#9
No description provided.