Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
"version": "11.1.0",
"description": "The JavaScript Content API Library a.k.a. Content API is an interface handling data coming from the FirstSpirit CaaS and the Navigation Service.",
"keywords": [],
"main": "dist/fsxa-api.cjs.js",
"module": "dist/fsxa-api.es5.js",
"types": "dist/types",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: Any reason for the removal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/fsxa-api.es5.js",
"require": "./dist/fsxa-api.cjs.js"
}
Expand Down
4 changes: 1 addition & 3 deletions proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have these lines been removed?

"module": "dist/fsxa-proxy-api.es5.js",
"types": "dist/types",
"author": "Justin Wiegmann <justin.wiegmann@crownpeak.com>",
"contributors": [
"Nicolai McAlley <nicolai.mcalley@crownpeak.com>"
Expand All @@ -15,6 +12,7 @@
],
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"import": "./dist/fsxa-proxy-api.es5.js",
"require": "./dist/fsxa-proxy-api.cjs.js"
}
Expand Down
Loading