Fix(package.json) add types to exports and remove redundant entry point fields#244
Conversation
jodeleit-es
left a comment
There was a problem hiding this comment.
Changes for package-lock.json and proxy/package-lock.json are missing.
| "name": "fsxa-proxy-api", | ||
| "version": "11.1.0", | ||
| "description": "This package represents the proxy version of the JavaScript Content API Library, running on the client side.", | ||
| "main": "dist/fsxa-proxy-api.cjs.js", |
There was a problem hiding this comment.
Why have these lines been removed?
| "keywords": [], | ||
| "main": "dist/fsxa-api.cjs.js", | ||
| "module": "dist/fsxa-api.es5.js", | ||
| "types": "dist/types", |
There was a problem hiding this comment.
Same here: Any reason for the removal?
There was a problem hiding this comment.
These fields were removed because the package already defines an exports map, which takes precedence over the legacy entry fields.
According to the Node.js documentation, when "exports" is present it becomes the primary entry point definition and overrides "main":
“If both exports and main are defined, the exports field takes precedence over main.”
https://nodejs.org/api/packages.html#package-entry-points
Modern tooling (including TypeScript ≥4.7) also resolves modules via the exports field and will look for type definitions there if an export map exists. In the previous configuration the exports map did not expose any type definitions, which meant TypeScript could not resolve the package types even though "types" existed at the top level.
TypeScript documentation:
https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports
By moving the type definition into the export map
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/fsxa-api.es5.js",
"require": "./dist/fsxa-api.cjs.js"
}
}
the types are properly discoverable again when importing the package.
Since exports already defines the public entry points for both runtime and types, the legacy main, module, and types fields become redundant and can be safely removed.
|
Thx for the clarification. |
fix for #242
The types export was previously missing in package.json, which caused TypeScript types to no longer be exported starting from version 11.1.0.
Additionally, the exports field had been introduced but the existing types, main, and module fields were still present. When exports is defined, these fields are effectively ignored unless they are explicitly specified within exports.
This PR removes the redundant types, main, and module fields and adds the missing types entry to the exports configuration.