Prepublish includes three transpiler configurations:
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
To offer separate NodeJS and Browser builds use one of the following keys for the browser bundle:
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.
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:
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:
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.
$ npm install --save-dev prepublish
$ yarn add --dev prepublish
Prepublish comes with a binary which can be called from within your
There is also some amount of parameters you can use if the auto detection of your library does not work out correctly.
Options --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]
$ npm test).
Sebastian Software GmbH