Skip to content

cloudprizm/babel-preset-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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.

About

Babel Node.js preset for typescript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published