Publishing to npm and Semantic Versioning
package.json fields (main, module, exports), changelogs, semantic-release, npm publish flow.
Preparing to Publish
Publishing makes your library installable via npm install. Before that, package.json must declare the entry points correctly and you must control what files ship.
main and module
main points to the CommonJS build for older tools; module points to the ESM build so modern bundlers pick the tree-shakeable version.
{
"main": "./dist/my-ui-lib.cjs.js",
"module": "./dist/my-ui-lib.es.js"
}All lessons in this course
- Vite Library Mode Configuration
- TypeScript Declarations for Component Libraries
- Tree-Shaking and Auto-Import
- Publishing to npm and Semantic Versioning