Skip to content

Commit c56c6eb

Browse files
clydinprofanis
authored andcommitted
docs: add tslib update migration docs (angular#37402)
This adds documentation for the v10.0 tooling migration `update-libraries-tslib` contained within the `@schematics/angular` package. PR Close angular#37402
1 parent 597c18f commit c56c6eb

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.pullapprove.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ groups:
963963
'aio/content/guide/workspace-config.md',
964964
'aio/content/guide/migration-solution-style-tsconfig.md',
965965
'aio/content/guide/migration-update-module-and-target-compiler-options.md',
966+
'aio/content/guide/migration-update-libraries-tslib.md',
966967
])
967968
reviewers:
968969
users:
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# tslib Direct Dependency Migration
2+
3+
## What does this migration do?
4+
5+
If you have any libraries within your workspace, this migration will convert `tslib` peer dependencies to direct dependencies for the libraries.
6+
TypeScript uses the `tslib` package to provide common helper functions used in compiled TypeScript code.
7+
The `tslib` version is also updated to `2.0.0` to support TypeScript 3.9.
8+
9+
Before:
10+
```json
11+
{
12+
"name": "my-lib",
13+
"version": "0.0.1",
14+
"peerDependencies": {
15+
"@angular/common": "^9.0.0",
16+
"@angular/core": "^9.0.0",
17+
"tslib": "^1.12.0"
18+
}
19+
}
20+
```
21+
22+
After:
23+
```json
24+
{
25+
"name": "my-lib",
26+
"version": "0.0.1",
27+
"peerDependencies": {
28+
"@angular/common": "^9.0.0",
29+
"@angular/core": "^9.0.0"
30+
},
31+
"dependencies": {
32+
"tslib": "^2.0.0"
33+
}
34+
}
35+
```
36+
37+
## Why is this migration necessary?
38+
39+
The [`tslib`](https://github.com/Microsoft/tslib) is a runtime library for Typescript.
40+
The version of this library is bound to the version of the TypeScript compiler used to compile a library.
41+
Peer dependencies do not accurately represent this relationship between the runtime and the compiler.
42+
If `tslib` remained declared as a library peer dependency, it would be possible for some Angular workspaces to get into a state where the workspace could not satisfy `tslib` peer dependency requirements for multiple libraries, resulting in build-time or run-time errors.
43+
44+
As of TypeScript 3.9 (used by Angular v10), `tslib` version of 2.x is required to build new applications.
45+
However, older libraries built with previous version of TypeScript and already published to npm might need `tslib` 1.x.
46+
This migration makes it possible for code depending on incompatible versions of the `tslib` runtime library to remain interoperable.
47+
48+
49+
## Do I still need `tslib` as a dependency in my workspace `package.json`?
50+
51+
Yes.
52+
The `tslib` dependency declared in the `package.json` file of the workspace is used to build applications within this workspace, as well as run unit tests for workspace libraries, and is required.

0 commit comments

Comments
 (0)