1.0.0-beta.2 โข Published 4 years ago
dir2pkg v1.0.0-beta.2
Small CLI to help to split big JS codebases into packages.
Moves dirs, creates boilerplate and creates the "dependencies" field of the new package with these benefits:
- ๐งน dependencies used in the code but missing from the package.json are added.
- โ only dependencies used in the code are listed.
- โ dependencies not used in the code are removed.
Node.js v16.13 or newer is required.
Via the yarn client:
$ yarn global add dir2pkgVia the npm client:
$ npm install -g dir2pkg$ dir2pkg --in-dir some-dir --out-dir packages/some-dir --pkg-json-name "@org/new-pkg" --pkg-json-path ./package.json--in-dir, -i
$ dir2pkg --in-dir some-dirIn directory
--out-dir, -o
$ dir2pkg --out-dir packages/some-dirOut directory
--pkg-json-name, -n
$ dir2pkg --pkg-json-name "@org/new-pkg"Package name
--pkg-json-path, -j
$ dir2pkg --pkg-json-path ./package.jsonHost package.json path
--ignore, -d
$ dir2pkg --ignore "shared" --ignore "@org/internal-alias"List of dependencies to ignore. Useful for ignoring internal alias that can't be resolved to one node_modules dep.
--force-peer-dep, -f
$ dir2pkg --force-peer-dep react --force-peer-dep react-domList of dependencies to force as peer dependencies. Useful for libraries like react.
# install deps
$ yarn
# build and watch for changes
$ yarn build --watch
# link dir2pkg globally
$ yarn link
# enjoy!
$ dir2pkg --help