Skip to content

Latest commit

 

History

History
96 lines (71 loc) · 5.63 KB

File metadata and controls

96 lines (71 loc) · 5.63 KB

@cabify/package-build

All Contributors

Package build configuration based on Rollup to compile JS packages.

Usage

Install this package as a dev dependency in your package, then create scripts in your package.json invoking it like this:

  "dist": "package-build",
  "dist:watch": "package-build -w",

NOTICE: this package doesn't clean your build directories in each run, so you'd probably want to append something like rimraf to your dependencies.

Parameters

  • -w to watch the files.
  • -p to define a different tsconfig.ts file. p.eg: package-build -p tsconfig.build.json.
  • -m or --preserve-modules to enable tree-shaking optimization (see below).

Tree Shaking Optimization

For libraries with many exports (like icon libraries), use the --preserve-modules flag to generate individual files instead of a single bundle:

package-build --preserve-modules
package-build -m

This enables effective tree-shaking for consumers using modern bundlers. When enabled:

  • Output files are generated in dist/ (CJS) and es2015/ (ESM) directories
  • The source directory structure is preserved
  • Each module becomes a separate file instead of being bundled into one

Recommended package.json configuration for tree-shakable libraries:

{
  "sideEffects": false,
  "exports": {
    ".": {
      "import": "./es2015/index.js",
      "require": "./dist/index.js"
    }
  }
}

Publish a new version

  • Update CHANGELOG with new features, breaking changes, etc
  • Check you're in main branch and everything is up-to-date.
  • Run yarn publish:<major|minor|patch> or yarn publish:canary for canary versions.
  • Run git push && git push --tags
  • Check all test actions triggered after previous push are ✔️.
  • Go to create a new release, select previously pushed tag and write a Title.
  • Check the action for publish the npm has finished with success.
  • Check on npm package webpage, the version has been published successfully under latest tag.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Alejandro

💻

Alejandro Gallardo Escobar

💻

Alejandro León

💻

Alex Temina

💻

Arian Zargaran

💻

Crismmgg

💻

Francisco Sánchez

💻

Javier López

💻

Valentin Berlin

💻

This project follows the all-contributors specification. Contributions of any kind welcome!