Skip to content

zkochan/publish-packed

Repository files navigation

publish-packed

npm version Status

Publishes a package together with its dependencies

When publishing a package, dependencies are not bundled with the package. Although you could use bundledDependencies, you have to list all the dependencies you want to bundle.

publish-packed bundles all dependencies with your package:

  1. it installs all your dependencies first

  2. it moves the node_modules folder from the root of your package to lib/node_modules

    When publishing, npm ignores the node_modules folder in the root of your package. However, it packs all node_modules in subfolders.

  3. it escapes the dependencies field in your package's package.json, so during installation no dependencies of your package will be installed, except optional dependencies.

  4. it can prune node_modules, removing markdown files, tests, configs and other resources that are not code

Limitations:

  1. you can use publish-packed only if all your source code is in the lib/ directory because all your dependencies are going to be inside lib/node_modules.
  2. you can use publish-packed only if your prod dependencies don't have lifecycle events like postinstall that should be executed during installation

Installation

<npm|pnpm|yarn> add -D publish-packed

Usage

Add publish-packed to the prepublishOnly and postpublish scripts of your package.json:

  "scripts": {
    "prepublishOnly": "publish-packed",
    "postpublish": "publish-packed"
  }

To publish the package, just run <npm|pnpm|yarn> publish.

License

MIT © Zoltan Kochan

About

Publishes a package together with its dependencies

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published