I'm in the process of creating a TypeScript library and I'd like to use the exports
field in the package.json
file for exporting.
After consulting nodejs and webpack's documentation, it seems that using the exports
field is the recommended approach for module exports.
For more information, check out: https://nodejs.org/api/packages.html#package-entry-points
You can also refer to this link for guidance: https://webpack.js.org/guides/package-exports/
The traditional method involves utilizing the "main", "types", and "module" fields.
How do I go about exporting type declarations using this new method? Should I continue using the "types" field or is there an alternative if multiple exports are involved?
Below is an example of the export setup I currently have:
"exports": {
".": {
"import": "./dist/A.mjs",
"require": "./dist/A.js"
},
"./A": {
"import": "./dist/A.mjs",
"require": "./dist/A.js"
},
"./B": {
"import": "./dist/B.mjs",
"require": "./dist/B.js"
}
}