vinyl-tf-babel
raw JSON → 0.1.0 verified Sat Apr 25 auth: no javascript
A Vinyl Transformer for Babel that integrates Babel compilation into vinyl-fs pipelines or Gulp. Version 0.1.0 is the latest stable release. It requires babel-core as a peer dependency and supports both ES modules and CommonJS. Differentiators include a class-based transformer (`BabelTransformer`) and a convenience function (`transform`) for Gulp, aligning with vinyl transformer standards.
Common errors
error Error: Cannot find module 'babel-core' ↓
cause babel-core is not installed: it's a peer dependency not bundled with vinyl-tf-babel.
fix
npm install babel-core
error TypeError: transformer is not a function ↓
cause Using default import incorrectly or forgetting to call new BabelTransformer.
fix
Use
new BabelTransformer() or transform() accordingly. Warnings
gotcha babel-core must be installed separately; calling without it will throw 'Cannot find module babel-core'. ↓
fix Install babel-core as a dependency: npm install babel-core
deprecated babel-core is deprecated in favor of @babel/core. This transformer may not work with @babel/core directly. ↓
fix Use vinyl-tf-babel with babel-core 6.x or switch to a transformer like gulp-babel.
gotcha Options passed to BabelTransformer or transform are forwarded directly to Babel; invalid options may cause silent failures. ↓
fix Consult Babel options documentation and validate configuration.
gotcha This package is a Vinyl Transformer; it expects Vinyl objects in the stream. Using with non-Vinyl streams may cause errors. ↓
fix Ensure the stream provides Vinyl file objects (e.g., from gulp.src or vinyl-fs src).
Install
npm install vinyl-tf-babel yarn add vinyl-tf-babel pnpm add vinyl-tf-babel Imports
- BabelTransformer wrong
const BabelTransformer = require('vinyl-tf-babel').BabelTransformercorrectimport { BabelTransformer } from 'vinyl-tf-babel' - transform wrong
const transform = require('vinyl-tf-babel').transformcorrectimport { transform } from 'vinyl-tf-babel' - default import wrong
const vinylTfBabel = require('vinyl-tf-babel')correctimport vinylTfBabel from 'vinyl-tf-babel'
Quickstart
import gulp from 'gulp';
import { transform as babel } from 'vinyl-tf-babel';
gulp.task('babel', () => {
return gulp.src('src/**/*.js')
.pipe(babel({ presets: ['@babel/preset-env'] }))
.pipe(gulp.dest('dist'));
});