grunt-babel is a Grunt plugin that integrates Babel, allowing developers to transpile modern JavaScript code (ESNext) into backward-compatible versions for older environments using the Grunt task runner. The current stable version is v8.0.0, which is specifically designed for compatibility with Babel 7.x. While Grunt itself has a slower release cadence compared to modern build tools, `grunt-babel` follows Babel's major version releases closely, necessitating updates to maintain compatibility. Its primary differentiator is its deep integration into the Grunt ecosystem, providing a familiar configuration experience for projects already utilizing Grunt for their build processes. It leverages Babel's extensive plugin and preset system, enabling a wide range of transformations, from JSX and TypeScript syntax stripping to polyfilling modern JavaScript features, making it suitable for projects that prefer a Grunt-centric workflow over newer alternatives like Webpack or Rollup.
npm install grunt-babelVerified import paths — ran on the pinned version, not inferred.
This quickstart configures grunt-babel to transpile 'src/app.js' into 'dist/app.js' using source maps and the '@babel/preset-env' preset, then registers it as the default Grunt task.
Ensure all Babel packages are updated to their `@babel/` scoped versions (e.g., `npm install --save-dev @babel/core @babel/preset-env`) and configuration paths are adjusted accordingly.
Upgrade Node.js to a supported version (>=6.9 for grunt-babel v8), or explicitly install `grunt-babel@7` for Babel 6.x compatibility and Node.js v4-v5 support.
Manually install `@babel/core` (for v8+) or `babel-core` (for v7) in your project: `npm install --save-dev @babel/core`.
Verify your Babel configuration (presets, plugins) and report core transpilation issues on the official Babel GitHub repository.
Run `npm install --save-dev @babel/core` or `yarn add --dev @babel/core`.
Add a preset like `@babel/preset-env` to your `babel.options.presets` array: `presets: ['@babel/preset-env']`. Ensure the preset package is also installed.
Ensure `@babel/preset-env` is configured to transform modules, e.g., `presets: [['@babel/preset-env', { modules: 'commonjs' }]]`.