I am trying build a TypeScript library and want to export using exports
field in package.json
.
From nodejs and webpack’s documentation, I saw that exports
is the recommended way to export modules.
https://nodejs.org/api/packages.html#package-entry-points
https://webpack.js.org/guides/package-exports/
The old way is to use “main”, “types” and “module”.
How can I export type declaration using this method?
Should I keep using the “types” field? But what if I have multiple exports?
Here is a sample of exports I 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"
}
}