node package manager


Sponsored by Version Downloads Build Status Unix Build Status Windows Dependencies

Prepublish is a solution for simplifying pre-publishing typical JavaScript projects for publishing to NPM.


Prepublish includes three transpiler configurations:

  • Buble: Blazing fast ES2015+ transpiler where the goal is to have lightweight runtime code, too.
  • Babel Latest: Latest configuration of Babel. Includes all of ES2015/ES2016/ES2017. Plus some ES3 helpers for maximum compatibility. Plus Support for Object-Rest-Spread and Class Properties. Uses Transform-Runtime to externalize requirements to Polyfills. Resulting code needs all Polyfills for each library published with this tool. Typically by using services like or Babel Runtime aka CoreJS.
  • React Latest: Like Babel Latest but with React JSX transpilation. Plus support for encapsulating PropTypes. Plus optimization for constant elements during rendering.

Output Targets

Prepublish produces builds depending on the entries of your packages package.json. It supports building for CommonJS and well as producing output with ES Modules. Just add the relevant entries to the configuration.

  • CommonJS Output: main
  • ES Module Output: module (jsnext:main is deprecated)

To offer separate NodeJS and Browser builds use one of the following keys for the browser bundle: browser or web or browserify. These bundles are always exported as ES Modules as we have the assumption that they are bundled by another tool like Webpack on the road to the browser.

Classic & Modern

You are able to export modules for ES2015 compatible environments, too. This happens in parallel and typically requires some heavy lifting on the bundling phase with Webpack, too. This is because we are using non-standardized configuration keys in package.json. Typically just append :modern to your normal targets:

  • CommonJS Output for NodeJS with ES2015 kept intact: main:modern
  • ES Modules Output for NodeJS with ES2015 kept intact: module:modern
  • Browser Output as ES Modules with ES2015 kept intact: browser:modern

We are thinking of updating what we understand as modern regularly. Currently modern is not fixed by specific features we think of as modern but uses babel-preset-env for selecting some common base of modern browsers.

To make sense of all these new modules it would help to produce two different outputs. One for classic browsers and one for modern browsers. ES2015 enabled features are rapidly catching up in performance. Some features are pretty hard to rework for older browsers like Generators, Async/Await, or even Block Scope. Therefor we think there is no need for sending modern clients the fully transpiled code down the wire. Keep in mind that you have to implement some basic client detection to send one or the other file to the matching client.

Current modern set:

  • NodeJS 6
  • Safari 10
  • iOS 10
  • Edge 14
  • Chrome 53
  • Firefox 50

With this you should get almost everything of ES2015.

The modern builds makes a lot of sense during development as it results in shorter transpiler runtimes.


CSS and Assets





$ npm install --save-dev prepublish


$ yarn add --dev prepublish


Prepublish comes with a binary which can be called from within your scripts section in the package.json file.

  "prepublish": "prepublish"

There is also some amount of parameters you can use if the auto detection of your library does not work out correctly.

  --entry-node      Entry file for NodeJS target [default = auto]
  --entry-web       Entry file for Browser target [default = auto]

  --output-folder   Configure the output folder [default = auto]

  -t, --transpiler  Chose the transpiler/config to use. Either "react", "latest" or "buble". [default = react]
  -x, --minified    Enabled minification of output files
  -m, --sourcemap   Create a source map file during processing

  -v, --verbose     Verbose output mode [default = false]
  -q, --quiet       Quiet output mode [default = false]


  • Pull requests and stars are always welcome.
  • For bugs and feature requests, please create an issue.
  • Pull requests must be accompanied by passing automated tests ($ npm test).


Apache License; Version 2.0, January 2004


Sebastian Software GmbH Logo

Copyright 2016-2017
Sebastian Software GmbH