grunt-es6-module-wrap-default

raw JSON →
0.2.0 verified Fri May 01 auth: no javascript abandoned

Grunt plugin (v0.2.0) that wraps CommonJS and AMD modules generated by es6-module-transpiler so they can be required by their name rather than requiring `.default`. It helps transition from ES6 modules to CommonJS/AMD without changing consumer code. The plugin is minimal, specific to the es6-module-transpiler output, and provides a `type` option to choose between CJS and AMD wrapping. Release cadence is unknown; last release was 2014. It has no known alternatives for this exact use case.

error Warning: Task "es6_module_wrap_default" not found.
cause The task is not registered; grunt.loadNpmTasks was not called or the plugin is not installed.
fix
Add grunt.loadNpmTasks('grunt-es6-module-wrap-default'); to your Gruntfile.
error Fatal error: Unable to read task "es6_module_wrap_default" options.
cause Invalid configuration; the property name may be misspelled or options are not an object.
fix
Ensure your Gruntfile has a property named exactly 'es6_module_wrap_default' with valid options.
error No files matched.
cause The source file glob pattern is incorrect or the directory does not exist.
fix
Check the file paths and cwd in the files configuration.
gotcha Only works with output from es6-module-transpiler; other ES6 transpilers may not produce compatible modules.
fix Verify that your modules were generated by es6-module-transpiler.
deprecated es6-module-transpiler is deprecated; consider using Babel or TypeScript for ES6 module transpilation.
fix Migrate to Babel or TypeScript, which handle imports directly and do not require wrapping.
gotcha Task configuration uses 'es6_module_wrap_default' as the property name; misspelling or incorrect casing will not throw an error—silent failure.
fix Ensure the property name exactly matches 'es6_module_wrap_default'.
gotcha If no files are matched, the task completes without any output—no error.
fix Double-check file glob patterns and cwd.
npm install grunt-es6-module-wrap-default
yarn add grunt-es6-module-wrap-default
pnpm add grunt-es6-module-wrap-default

Registers the Grunt task and configures it to wrap CJS files from a source directory to an output directory, enabling require('name') instead of require('name').default.

// Install: npm install grunt-es6-module-wrap-default --save-dev
// In Gruntfile.js:
module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-es6-module-wrap-default');
  grunt.initConfig({
    es6_module_wrap_default: {
      options: {
        type: 'cjs'
      },
      files: [{
        expand: true,
        cwd: 'cjs/transpiled',
        src: ['**/*.js'],
        dest: 'cjs'
      }]
    }
  });
  grunt.registerTask('default', ['es6_module_wrap_default']);
};