kn-babel

0.0.3-develop • Public • Published

kn-babel

Ready-to-go no-muss Babel configuration.

Usage

npm install --save-dev kn-babel

Node module hook

This method is useful when you want to use Babel for development but don't want to wait for your code to compile. Typically only used in development or for "toy" packages, as there's a small (but noticeable) performance hit.

// index.js
require('kn-babel').register();
require('./some-file-that-needs-babel');

Generating a configuration

This method is useful when you need to generate Babel options to pass to a build tool such as Rollup or Webpack.

// rollup.config.js
import createBabelConfig from 'kn-babel';
import babel from 'rollup-plugin-babel';
 
export default {
  entry: 'main.js',
  dest: 'bundle.js',
  format: 'cjs',
  plugins: [
    babel(createBabelConfig({runtime: 'browser', modules: false})),
  ],
};

Options

createBabelConfig() accepts an object with the following properties, all of which are optional:

property type default description
runtime "node"|"browser" "node" Runtime environment for the produced code.
env "development"|"test"|"production" "development" Environment (typically NODE_ENV) for the produced code.
browsers string[] ['>1%', 'IE > 8', 'last 2 versions'] Browserslist strings identifying supported browsers.
useReactPreset boolean true If false, babel-preset-react will be disabled.
extraPlugins Object[] If supplied, will add passed plugins to plugins list.
modules "amd"|"umd"|"systemjs"|"commonjs"|false "commonjs" Sets module transformation.

Readme

Keywords

none

Package Sidebar

Install

npm i kn-babel

Weekly Downloads

3

Version

0.0.3-develop

License

MIT

Last publish

Collaborators

  • r24y