grunt-amd-namer

1.0.0 • Public • Published

grunt-amd-namer

Name anonymous AMD modules using AST parsing

Common Usage

This task is useful if you're using an AMD loader that requires modules to have explicit names (e.g. almond). This is especially useful if you're handling bundling yourself, as opposed to using r.js.

Output Example

input my-file.js

define(['a', 'b', 'c'], function(a, b, c) {
  console.log(+ b + c);
});

output my-file.js

define('my-file', ['a', 'b', 'c'], function(a, b, c) {
  console.log(+ b + c);
});

Getting Started

This plugin requires Grunt.

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-amd-namer --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-amd-namer');

The "amd_namer" Task

grunt.initConfig({
  amd_namer: {
    options: {
      baseUrl: 'dist/javascript'    
    },
    files: [
      {
        expand: true,
        cwd: 'src/javascript',
        src: ['**/*.js'],
        dest: 'dist/javascript'
      }
    ],
  },
})

Contributing

Feel free to open issues and send pull-requests.

Release History

  • 2015-09-07   v1.0.0   Must pass baseUrl option

License

Copyright (c) 2015 cowchimp. Licensed under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i grunt-amd-namer

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • cowchimp