0.1.5 • Published 5 years ago

@hungry/babel-preset-cli v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@hungry/babel-preset-cli

Babel preset for Node.js, with typescript and import/export syntax.

Install

yarn add @hungry/babel-preset-cli

Node API

// within node.js script
const { bootstrap } = require('@hungry/babel-preset-cli')
bootstrap()

// or more meaningful alias
const { enableRuntimeTranspilation } = require('@hungry/babel-preset-cli')
enableRuntimeTranspilation({
  matcher: (file: string) => boolean,
  extensions: [".ts", ".tsx", ".jsx", ...],
  presets: []
})

or within bash script

#!/usr/bin/env node --require @hungry/babel-preset-cli/register

Why I would need a node API for this

I had some issues with @babel/register in context of monorepo and multiple different presets. I did not want to each time build sources for my node libraries, so only answer was to enable runtime transpilation, however after preparing some stuff to opensource I had an issue with multiple presets. enableRuntimeTranspilation works similar to @babel/register but exposes matcher for file - you are in charge what would be transpiled, not any babel magic.