-
Notifications
You must be signed in to change notification settings - Fork 12k
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
docs: add linked library story #6292
Conversation
|
||
## The library needs to be AOT compatible | ||
|
||
Angular CLI does static analysis even without the `--aot` flag in order to detect lazy-loader routes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lazy-loaded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
## The library needs to be AOT compatible | ||
|
||
Angular CLI does static analysis even without the `--aot` flag in order to detect lazy-loader routes. | ||
If your library is not AOT compatible, you will likely get an static analysis error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get a static analysis error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
Angular libraries are usually built using TypeScript and thus require to be built before they | ||
are published. | ||
For simple cases a linked library might work even without a build step, but this is the exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cases,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
For simple cases a linked library might work even without a build step, but this is the exception | ||
rather than the norm. | ||
|
||
If a library is not being built using it's own build step, then it is being compiled by the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its own build step
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
Angular libraries should list all `@angular/*` dependencies as | ||
[Peer Dependencies](https://nodejs.org/en/blog/npm/peer-dependencies/). | ||
This insures that, when modules asks for Angular, they all get the exact same module. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that, when modules ask for Angular,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
If a library lists `@angular/core` in `dependencies` instead of `peerDependencies` then it might | ||
get a *different* Angular module instead, which will cause your application to break. | ||
|
||
While developing a library however, you'll need to have all of your peer dependencies also installed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
library,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
You should list all the peer dependencies that your library uses in `./tsconfig.json`, pointing | ||
them at the local copy in the apps `node_modules` folder. | ||
This ensures that your all will always load the local copies of the modules your library asks for. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will always
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
# Linked libraries | ||
|
||
While working on a library, it is common to use [npm link](https://docs.npmjs.com/cli/link) to | ||
have avoid reinstalling the library on every build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove "have"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
"@angular/common": [ | ||
"../node_modules/@angular/common" | ||
], | ||
"@angular/compiler": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could probably be simplified to just one:
"@angular/*": [
"../node_modules/@angular/*"
],
Works with tsc but would need to confirm it works with the CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked it and seems to be fine. Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking this as per PR description.
Blocked on angular#6276.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Blocked on #6276.
/cc @clydin