When publishing web components to NPM it’s convenient to use the main
property of package.json
to publish the bundled module like so.
"main": "build/index.bundle.js",
"module": "build/index.js",
"type": "module",
"types": "build/index.d.ts",
This also makes the bundled API available via the UNPKG CDN.
However I just want to make sure that applications that install the package don’t somehow reference code from the bundle, causing it to be included in the build, instead of from the types / objects / etc that the API exports via index.ts
, which has the corresponding javascript version set in the module
field.
So is it OK to set the fields like this with respect to using the package in downstream typescript builds?