It's perfectly okay if the library doesn't export the Angular module's name
property. Angular wasn't initially designed with JS modules in mind and primarily promotes the
angular.module('MyApp', ['moduleName'])
module definition style.
While exporting the name
from modules is a common convention, one can also do
import * as MyLibrary from 'MyLibraryPath';
and use it like
angular.module('MyApp', [MyLibrary]);
If there is no module export, you can work around it with the help of Webpack's exports-loader and
module: {
loaders: [
{
loader: 'exports-loader',
test: /path\/myLibrary\.js$/,
query: '"moduleName"'
}
],
},
configuration, which effectively injects module.exports = "moduleName";
into the module.
Feel free to use this workaround temporarily if you intend to contribute or report an issue for libraries that omit the export of name
. It's best not to complicate builds just for the sake of code consistency.