New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I use external library like moment.js in my angular package? #163
Comments
moment.js registers on the global scope with Import of moment.js in TypeScript According to #135, {
"lib": {
"externals": {
"moment": "moment"
}
}
} You can then use it with: import * as moment from 'moment'; |
If you want to use moment both with Rollup (bundling using ng-packagr) and Webpack (if you use the library's sources directly with Angualar CLI for example) you may find that the import * as momentNs from 'moment';
const moment = momentNs; |
…ndlers See ng-packagr/ng-packagr#163 for more info
Suggestion from @JoostK worked for me when I was trying to use import * as momentNs from 'moment-timezone';
const moment = momentNs; |
Currently using angular 6 library project and try to incorporate the moment.js in library project. Try the same solution which mention in above, Added moment in ng-package.json file "lib": { However still getting the same error. |
This externals didn't do much for me but using moment-es6 does. #290 (comment) |
Adding https://www.typescriptlang.org/docs/handbook/compiler-options.html |
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. |
Type of Issue
Description
Let's say I want to use momen.js library. When I do
ng-packgr will inline whole library to the bundle. How should I use it to act as peerDependecy so it would use packge installed in module where my library would be consumed?
By the way, despite the moment.js is inlined it seems it is not working when library is consumed by the target application :(
I use same configuration as in https://github.com/dherges/ng-packaged
The text was updated successfully, but these errors were encountered: