0.0.1 • Published 7 years ago

babel-plugin-amd-namer v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

babel-plugin-amd-namer

A Babel plugin to name anonymous AMD modules

This task is useful if you're using an AMD loader that requires modules to have explicit names (e.g. almond).

Example

Input src/simple/actual.js

define(function() {
  return 'a';
});

Output dist/simple/actual.js

'use strict';

define('dist/simple/actual', function () {
  return 'a';
});

Getting started

Installation

$ npm install babel-plugin-amd-namer

Usage

Via .babelrc (Recommended)

{
  "plugins": ["amd-namer"],
  "moduleIds": true, //mandatory!
  "sourceRoot": "src",
  "moduleRoot": "dist"
}

This plugin uses the same module naming logic as the built-in babel plugins (e.g. transform-es2015-modules-amd). This means that it calls the internal babel method getModuleName to decide what the module name should be. See the Babel Options docs for customization info.

Running tests

Run mocha tests with npm test

License

MIT