js-transpiler
raw JSON → 0.0.5 verified Fri May 01 auth: no javascript abandoned
A simple Gulp-based automation script for transpiling ES6 JavaScript to ES5 using Babel, with optional linting via ESLint (airbnb-base config). Copies JS files from source to destination, transpiles files that have an `/* eslint-env es6 */` header. Version 0.0.5, last release 2017. No longer actively maintained. Key differentiators: minimal configuration, RequireJS AMD module support, and file-level ES6 detection. Alternatives: direct use of Babel CLI or Webpack.
Common errors
error Error: Cannot find module 'babel-preset-env' ↓
cause Missing Babel preset dependency.
fix
Run
npm install --save-dev babel-preset-env. error TypeError: gulp.src(...).pipe is not a function ↓
cause Gulp v4 breaking change (stream-based instead of callback).
fix
Use Gulp v3 (
npm install gulp@^3.9.1) or switch to another tool. error Error: ESLint configuration is invalid ↓
cause Outdated eslint-config-airbnb-base version or missing plugins.
fix
Install compatible eslint and plugins:
npm install eslint@^4.0.0 eslint-config-airbnb-base@^12.0.0. Warnings
deprecated Package unmaintained since 2017. Not compatible with modern Babel (>=7) or ESLint (>=6). ↓
fix Use Babel CLI directly or update to a maintained alternative.
gotcha Only transpiles files with `/* eslint-env es6 */` comment (first line). Other files are copied as-is. ↓
fix Ensure all ES6 files start with the magic comment, or set `es6Pattern` option to a RegExp that matches.
breaking Requires Node >=7, but not tested on Node 10+. May fail due to deprecated Babel 6 APIs. ↓
fix Upgrade package or use Node 8/9 LTS.
gotcha Babel presets and plugins must be installed globally or locally; no automatic installation. ↓
fix Run `npm install babel-preset-env` (or desired preset) before use.
Install
npm install js-transpiler yarn add js-transpiler pnpm add js-transpiler Imports
- default wrong
import transpiler from 'js-transpiler';correctconst transpiler = require('js-transpiler'); - run
const { run } = require('js-transpiler'); - default wrong
import transpiler from 'js-transpiler';correctimport * as transpiler from 'js-transpiler'; transpiler.run(...)
Quickstart
const transpiler = require('js-transpiler');
transpiler.run({
path: {
src: './src/**/*.js',
dest: './dist'
},
useBabel: true,
babelrc: {
presets: ['env']
},
useLint: false
});
// Then run: gulp