Learn how package creation/publishing works, which would help greatly if you
- interested to contribute/understand open source code on GitHub
- want to level up your JavaScript debugging skill
- Create
- Consume
- Update
flowchart LR
Create -- Publish --> Consume
Consume -- Issues/Feedbacks --> Update
Update -- Publish --> Consume
- Figure out how to publish to certain registry with the right permissions (not covered today)
- Figure out how to configure the package so it can be consumed easily
- Figure out how to update and preview package changes with minimal overhead
We need a bundler for the following:
- additional processing like compile from TS to JS + type definitions.
- merge multiple files into single file so it's single entry points, so it's easier to consume
- generate multiple formats (CommonJS + ESM) so we can support multiple environments
My setup:
-
For single entry point,
main
for CommonJS/UMD formatmodule
for ESM formattypes
for typescript definition
-
For multiple entry points, use
exports
to define what are the entry points.
- Use
pnpm
workspace by preview changes by adding a playground/example as another "package" of the workspace. - With monorepo, you may not even need to publish package at all!
- Use
Verdaccio
to preview the behavior without actually publishing it.