Constellate Babel Compiler Plugin

raw JSON →
0.14.0 verified Fri May 01 auth: no javascript

A Babel compiler plugin for Constellate projects, Version 0.14.0. This plugin integrates Babel into the Constellate build pipeline, allowing transformation of JavaScript/TypeScript code. It is part of the Constellate monorepo and is released on npm. Use it to transpile modern JS to older syntax as part of a Constellate build. Alternatives include other compiler plugins like TypeScript or Terser. Note: This is a plugin meant to be used with the Constellate CLI, not standalone.

error Error: Cannot find module '@babel/core'
cause @babel/core is not installed.
fix
npm install @babel/core
error TypeError: babel is not a function
cause Importing incorrectly (e.g., default vs named).
fix
Use import babel from 'constellate-plugin-compiler-babel'.
error Plugin configuration error: Babel presets not applied
cause Presets not passed correctly to babel() call.
fix
Pass presets as array, e.g., babel({ presets: ['@babel/preset-env'] })
gotcha This plugin is meant to be used as part of Constellate, not as a standalone Babel wrapper. It does not expose a direct Babel API.
fix Use the plugin with Constellate's compile function.
deprecated The package uses an older naming convention and might be renamed in future Constellate versions.
fix Follow Constellate releases for migration.
gotcha Ensure @babel/core is installed in your project, as it's a peer dependency.
fix Run npm install @babel/core.
npm install constellate-plugin-compiler-babel
yarn add constellate-plugin-compiler-babel
pnpm add constellate-plugin-compiler-babel

Demonstrates importing the Babel plugin and using it with Constellate to compile a JavaScript file with @babel/preset-env.

import babel from 'constellate-plugin-compiler-babel';
import constellate from 'constellate';
const config = {
  plugins: [babel({ presets: ['@babel/preset-env'] })]
};
const result = await constellate.compile('src/index.js', config);
console.log(result.code);