Publishing a package to
npm from a monorepo can be an extremely satisfying and smooth experience, with the right tools.
You should follow this setup if you want to publish some of your monorepo's workspaces to
npm as packages. If you don't need to publish to
npm, you should use an internal package instead. They're much easier to set up and use.
You'll need to set up a few tools to get it working:
First, you'll need a bundler to turn your code into
CommonJS (opens in a new tab), the most commonly used format on
npm. You'll also need to set up a dev script so that you can work on the workspace in local development.
Finally, you'll need a tool for publishing & versioning. This will handle both bumping your monorepo's package versions and publishing to npm.