angular-library-starter | Angular library compatible with AoT compilation | Reactive Programming library
kandi X-RAY | angular-library-starter Summary
kandi X-RAY | angular-library-starter Summary
Build an Angular library compatible with AoT compilation and Tree shaking like an official package
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular-library-starter
angular-library-starter Key Features
angular-library-starter Examples and Code Snippets
Community Discussions
Trending Discussions on angular-library-starter
QUESTION
I have an Angular 5 library project and I want to use momentjs
version 2.20.1
.
I followed moment docs on how to install for TypeScript and for the most part everything works. When I test my library using ng test
I have no problems however when I try to package the lib with npm run build
I get
Cannot call a namespace ('moment')
when using import * as moment from 'moment';
. And I get
moment has no default export.
when using import moment from 'moment';
and setting "allowSyntheticDefaultImports": true
.
How do I properly install and use momentjs
?
ANSWER
Answered 2018-Feb-07 at 09:07try...
QUESTION
I'm settings up a common library for all my Angular 5 projects. Library is a clone of GitHub repository angular-library-starter-kit.
Everything works fine until I try to use HttpClientModule
(successor to HttpModule
).
Here are contents of my library.module.ts
file:
ANSWER
Answered 2018-Jan-22 at 11:47I poorly read the GitHub Issue. Apparently when working with local libraries you have to add --preserve-symlinks
argument to ng serve
.
QUESTION
I'm developing an Angular lib (GitHub repo link), there are
- lib module sources placed at
./src
- test App sources placed at
./app
- lib distributive at
./dist
The build process uses rollup.js and is based on angular-library-starter.
I also have a process that generates npm package from ./dist
and installs it to ./node_modules
. The issue is that the App works fine with the lib module imported from ./src
and does not work when I imported it from ./dist
or ./node_modules
:
ANSWER
Answered 2018-Jan-13 at 20:23I believe this is a build process responsibility.
Seems you're right. We usually inline template during the build process.
In order to do you can create js file like:
/utils/inline-resouces.js
QUESTION
I'm trying to create a package using Angular library starter
Everything works fine until I add RouterModule.
The module that causes an issue
...ANSWER
Answered 2018-May-24 at 05:39If this is a library or a module that will be imported into other libraries/modules you SHOULD NOT call the .forRoot()
function when you pass it into the @NgModule
.
RouterModule declares and exports some directives, e.g. router-outlet, routerLink, routerLinkActive etc. Also, it provides some services e.g. Router, ActivatedRoute etc. To avoid having multiple instances of services, RouterModule defines two methods, "forRoot" and "forChild". As the name suggests, "forRoot" method should be called only by root module, i.e. app.module, and forChild should be called by other feature modules. This way, you still get to use directives, components, pipes exported by this module and don't get new instances of services.
While this doesn't specifically get the root of your issue, it will likely resolve your issue. (Also this issue may help)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install angular-library-starter
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page