alamode
alamode
is a RegExp-based transpiler of source code in Node.js. It is a fast, low-weight alternative to AST-based transpilers, such as @babel
.
Table Of Contents
Installation
alamode
can be either installed globally, or as a library. The library can be used either programmatically, or via package.json
to refer to a binary in node_modules/.bin
from a yarn
or npm
script.
Global
Install as a global binary from CLI and use to transpile source code files.
Installation Command | Usage Command |
---|
npm i -g alamode
| yarn build |
src
└── index.js
build
├── index.js
└── index.js.map
|
Dependency
Install as a dependency and use API to run programmatically in other Node.js software, or access the alamode
binary via a yarn
or npm
script.
Installation Command | Usage Command |
---|
yarn add -DE alamode
| node build |
import alamode from 'alamode'
const src = 'src'
const output = 'build'
;(async () => {
await alamode({
src,
output,
})
})()
|
yarn build | npm run build |
// package.json
{
"name": "project",
"version": "1.0.0",
"description": "Example.",
"main": "build",
"scripts": {
"test": "zoroaster test/spec",
"build": "alamode src -o build"
},
"files": [
"build"
],
"license": "MIT",
"devDependencies": {},
"dependencies": {}
}
|
Demo
In the demo below, a project's src
directory is transpiled to replace import
and export
statements and placed in the build
directory.
CLI
alamode src -o build
API
The package is available by importing its default function:
import alamode from 'alamode'
alamode(
arg1: string,
arg2?: boolean,
): void
Call this function to get the result you want.
import alamode from 'alamode'
(async () => {
await alamode()
})()
Copyright
(c) À La Mode 2018