meteor-babel
raw JSON → 7.10.7 verified Sat Apr 25 auth: no javascript
A Babel wrapper package designed specifically for use with the Meteor framework, currently at v7.13.0. It provides a pre-configured Babel compilation pipeline that integrates seamlessly with Meteor's build system, supporting ES6/ES7 transpilation, TypeScript, and various syntax transformations. Differentiators include Meteor-specific plugins, automatic dependency management, and compatibility with Meteor's module system. Release cadence is irregular, with major version bumps tied to Meteor updates. vs. plain Babel: adds Meteor-specific transforms and optimizations, eases configuration for Meteor projects.
Common errors
error Error: Cannot find module 'meteor-babel' ↓
cause Package not installed or misspelled.
fix
Run 'npm install meteor-babel' and ensure import path is correct.
error TypeError: meteorBabel.compile is not a function ↓
cause Importing default instead of named 'compile'.
fix
Use 'import { compile } from 'meteor-babel''.
error SyntaxError: Unexpected token => ↓
cause Source code not transpiled; compile() not used or options missing.
fix
Ensure compile() is invoked on the source with correct options like { presets: ['meteor'] }.
error Error: Could not find any Babel presets or plugins ↓
cause Missing Babel configuration.
fix
Add a .babelrc file with presets/plugins or pass options to compile().
Warnings
breaking In v7.11.0, default Babel plugins changed. Existing projects may break if relying on removed plugins. ↓
fix Update your .babelrc or Babel configuration to explicitly include any missing plugins.
deprecated setCacheDir() is deprecated as of v7.12.0; caching is now automatic. ↓
fix Remove calls to setCacheDir(); no action needed.
gotcha meteor-babel requires Node.js >= 10. Installing on older Node versions may fail silently. ↓
fix Upgrade Node.js to version 10 or higher.
breaking In v7.13.0, the 'loose' option for class transforms changed default behavior. See migration guide. ↓
fix Set 'loose' option explicitly in Babel config if relying on previous behavior.
gotcha When using with Meteor, do not call compile() directly in production; use Meteor's build plugin. ↓
fix Use the meteor-babel package only as a dependency for Meteor's build system, not for direct invocation.
Install
npm install meteor-babel yarn add meteor-babel pnpm add meteor-babel Imports
- meteorBabel wrong
const meteorBabel = require('meteor-babel')correctimport meteorBabel from 'meteor-babel' - compile wrong
const compile = require('meteor-babel').compilecorrectimport { compile } from 'meteor-babel' - setCacheDir wrong
import setCacheDir from 'meteor-babel/setCacheDir'correctimport { setCacheDir } from 'meteor-babel'
Quickstart
import meteorBabel from 'meteor-babel';
import { compile } from 'meteor-babel';
const sourceCode = `
const x = (a, b) => a + b;
export default x;
`;
// Compile with default options
const result = compile(sourceCode, {});
console.log(result.code);
// Or use the meteorBabel object for more control
const babelInstance = new meteorBabel.Babel();
const transformed = babelInstance.transform(sourceCode, {
filename: 'test.js',
sourceMaps: true,
});
console.log(transformed.code);