grunt-es6-module-transpiler
raw JSON → 0.5.0 verified Fri May 01 auth: no javascript deprecated
A Grunt task for processing ES6 module import/export syntax into AMD, CommonJS, or globals using the es6-module-transpiler. Current stable version: 0.5.0. Released infrequently, last update 2013. Differentiators: integrates with Grunt build system, offers transpile:enable task to temporarily enable ES6 modules for other tasks. Note: outdated and unmaintained, the underlying transpiler is superseded by Babel.
Common errors
error Error: Cannot find module 'es6-module-transpiler' ↓
cause Missing runtime dependency es6-module-transpiler.
fix
npm install es6-module-transpiler --save-dev
error Warning: Task "transpile" not found. Use --force to continue. ↓
cause Plugin not loaded or not installed.
fix
Ensure grunt-es6-module-transpiler is installed and grunt.loadNpmTasks('grunt-es6-module-transpiler'); is called.
error TypeError: Cannot read property 'files' of undefined ↓
cause Missing or incorrect Grunt configuration for transpile task.
fix
Add a transpile configuration block in grunt.initConfig as shown in the docs.
Warnings
deprecated This plugin and its underlying es6-module-transpiler are deprecated in favor of Babel. ↓
fix Migrate to @babel/preset-env or @babel/plugin-transform-modules-commonjs with Grunt via grunt-babel.
gotcha The transpiler forces strict mode, causing issues with libraries like Chai that use arguments.callee. ↓
fix Switch to expect.js or another assertion library that works in strict mode.
breaking Node >= 0.8.0 required, may not work with recent Node versions. ↓
fix Use a compatible Node version or migrate to a modern transpiler.
Install
npm install grunt-es6-module-transpiler-rhengles yarn add grunt-es6-module-transpiler-rhengles pnpm add grunt-es6-module-transpiler-rhengles Imports
- transpile wrong
grunt.loadNpmTasks('grunt-es6-module-transpiler'); // correct, no common mistakecorrectgrunt.loadNpmTasks('grunt-es6-module-transpiler'); - transpile:enable wrong
grunt.registerTask('test', ['transpile', 'mocha']); // runs transpile task instead of enablingcorrectgrunt.registerTask('test', ['transpile:enable', 'mocha']);
Quickstart
// Gruntfile.js
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-es6-module-transpiler');
grunt.initConfig({
transpile: {
main: {
type: 'cjs',
files: [{
expand: true,
cwd: 'lib/',
src: ['**/*.js'],
dest: 'tmp/'
}]
}
}
});
grunt.registerTask('default', ['transpile']);
};