@darkobits/publish-root

1.0.0 • Public • Published

publish-root

NPM Version david Code Style

In large/complex packages, it is often handy to utilize the filesystem in addition to exports to organize and namespace things. However, it can be obnoxious to require your consumers to include a path segment like dist when importing a module from your package; it bears no semantic meaning and is often required on every import because it's where all of your package's build artifacts live.

This package attempts to address that issue. Tell it what folder your build artifacts are in, and it ensures your tarballs are packed correctly.

Setup

Install:

$ npm install @darkobits/publish-root

Then, add the following scripts to your project's package.json:

"scripts": {
  "prepack": "pr:pre",
  "postpack": "pr:post"
}

It is assumed that your build artifacts are located in dist. If this is not the case, you may indicate where they are by passing an argument to pr:pre:

"scripts": {
  "prepack": "pr:pre foo"
}

To do a dry run, you can run npm pack (set the LOG_LEVEL environment variable to verbose for additional logging) and inspect the contents of the tarball it produces:

$ npm pack
$ tar -tvf your-package-name-1.2.3.tgz

You do not need to change anything in package.json; relevant fields will be re-written and restored automagically.


This approach has the following benefits:

  • Works with Lerna (install in each package, not at the root)
  • Does not break npm link.

See Also

 


Readme

Keywords

none

Package Sidebar

Install

npm i @darkobits/publish-root

Weekly Downloads

0

Version

1.0.0

License

WTFPL

Last publish

Collaborators

  • darkobits