I am building an Angular library and the client of the library needs to use it as a UMD module. I have the need to use some libraries such as date-fns. When building the library it throws the following warnnings:
Bundling to UMD
WARNING: No name was provided for external module 'date-fns/locale' in output.globals – guessing 'locale'
WARNING: No name was provided for external module 'date-fns' in output.globals – guessing 'dateFns'
WARNING: No name was provided for external module 'date-fns-tz' in output.globals – guessing 'dateFnsTz'
I am using the ng-packagr to bundle the library and the libraries that have a UMD module can have the external name fixed in the ng-package.json file liek the following:
{
...
"lib": {
"umdModuleIds": {
"ngx-mask": "ngx-mask",
...
},
...
The ng-packagr creates a UMD module file that inside expects to find a dateFns
in the global scope (global.dateFns
). The problem is that the date-fns
library does not provide a UMD module for the current version that the client can use. Is there a way to provide the necessary date-fns
code inside the UMD bundle (the best option would be to make use of the tree-shacking capabilities but if not, include all date-fns
code is also an option)? Or any workaround the client can do when using my library UMD?