Installation
Despite all the recent advancements in the npm ecosystem, setting up a TypeScript (or JavaScript) package is still quite tedious and non-trivial. Packemon hopes to alleviate this problem, and can be integrated into existing projects, or used to scaffold a new project.
Scaffold a new project
Starting from scratch? Let Packemon scaffold the entire project structure for you! Run the
packemon scaffold
command below, select a template, answers some questions, and let
Packemon work its magic. View the scaffold docs for more information on our supported templates.
- Yarn 2+
- Yarn 1
- npm
yarn dlx packemon scaffold ./mylib
npx packemon scaffold ./mylib
npx packemon scaffold --packageManager npm ./mylib
Scaffolding a new project will...
- Align with the defined file structure.
- Create config files for common developer tools (Babel, ESLint, Vitest, TypeScript, etc), based on moonrepo presets.
- Create package specific files like
package.json
, readme's, and licenses. - Create example source and test files.
- Install dependencies with the chosen package manager.
Add to an existing project
To add Packemon to an existing project, install packemon
as either a development or global
dependency. Once installed, you will need to configure each package by running the
packemon init
command. Be sure your project abides the defined requirements!
- Yarn
- npm
yarn add --dev packemon
yarn packemon init
npm install --save-dev packemon
npx packemon init
Furthermore, you can now reference the packemon
binary within a package.json
script. We suggest
the following build
(for development) and pack
(for production) scripts.
{
"name": "package",
"scripts": {
"build": "packemon build",
"pack": "packemon pack --addEngines --addFiles --declaration"
}
}
Configure Babel
Packemon relies on its own internal Babel configuration for building packages, but if you want to
use the same configuration for local development and testing, update your root babel.config.js
to
the following.
const { createRootConfig } = require('packemon/babel');
module.exports = createRootConfig();
If you're using workspaces and certain packages require additional configuration that the root does
not provide (for example the React preset), you can
create branch relative .packemon.js
config.