A Babel plugin to name anonymous AMD modules
This plugin is useful if you're using an AMD loader that requires modules to have explicit names (e.g. almond).
Input src/simple/actual.js
define(function() {
return 'a';
});
Output dist/simple/actual.js
'use strict';
define('dist/simple/actual', function () {
return 'a';
});
$ npm install babel-plugin-amd-namer
{
"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.
Run mocha tests with npm test
MIT