Registry / devops / metalsmith-babel

metalsmith-babel

JSON →
library5.1.0jsnpmunverified

A Metalsmith plugin that transpiles JavaScript files using Babel. Current stable version is 5.1.0, released 2018-09-03. Maintained under the babel organization. Allows specifying Babel options like presets and plugins. Useful for integrating Babel into a static site build pipeline with Metalsmith. Different from using Babel standalone as it operates on Metalsmith file objects.

npm install metalsmith-babel
INSTALL
IMPORT
SIG · METALSMITH-BABEL
M
metalsmith-babel
devopsjavascriptv5.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

babel
const babel = require('metalsmith-babel');
import babel from 'metalsmith-babel';
Package is CommonJS only. ES modules are not supported.
babel (as function call)
.use(babel({ presets: ['@babel/preset-env'] }))
.use(require('metalsmith-babel'))
The plugin must be called as a function with Babel options, not passed directly.

Shows how to use metalsmith-babel with Metalsmith API, passing Babel options.

const Metalsmith = require('metalsmith'); const babel = require('metalsmith-babel'); new Metalsmith('./source') .use(babel({ presets: ['@babel/preset-env'] })) .build((err, files) => { if (err) throw err; console.log('Build complete.'); });
Debug
Known issues
breakingThe package does not work with Babel 6. It requires Babel 7+ (@babel/core). Using Babel 6 presets will fail.
fix
Install @babel/core and @babel/preset-env instead of babel-core and babel-preset-env.
affects: >=5.0.0
deprecatedIn version 5.0.0, the package dropped support for Node.js < 6.
fix
Upgrade Node.js to 6 or higher.
affects: >=5.0.0
gotchaThe plugin does not process files in node_modules by default. Must manually filter.
fix
Use a pattern like '**/*.js' and exclude node_modules via metalsmith ignore.
affects: >=3.0.0
breakingVersion 4.0.0 changed from babel-core to @babel/core, breaking all existing setups using babel-preset-* packages.
fix
Update dependencies to @babel/core and @babel/preset-* packages.
affects: <5.0.0 -> >=4.0.0
Errors
Common errors & fixes
Error: Cannot find module '@babel/core'
@babel/core is not installed.
fix
npm install --save-dev @babel/core
TypeError: babel is not a function
The plugin is not called as a function; require returns the function itself.
fix
Use .use(babel({...})) instead of .use(require('metalsmith-babel'))
Error: Requires Babel "7.x", but was loaded with "6.x"
Babel 6 is installed instead of Babel 7.
fix
Upgrade to @babel/core and @babel/preset-env
Upgrade
Version history
5.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
metalsmith-babel — npm install metalsmith-babel · libregistry