Angular-cli: tslib is automatically added to dependencies

Created on 12 Mar 2019  路  4Comments  路  Source: angular/angular-cli

馃悶 Bug report

Command (mark with an x)


- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?


I don't think so

Description

I have a super small Angular library which I want to not have dependencies at all. It only has peer dependencies for @angular/core and @angular/forms. I've removed importHelpers flag from all tsconfig files as I've noticed that my generated js code does not have any tslib mentions. However when I do ng build in generated package.json I still get

  "dependencies": {
    "tslib": "^1.9.0"
  }

馃敩 Minimal Reproduction

I've made a basic workspace with a library using Angular CLI:

ng new foo --create-application=false
cd foo
ng generate library foo-lib

Then I wrote my mini library, removed all tslib references from all package.json files and all importHelpers flags from all tsconfig.json files. Then I did npm i and ran:

ng build

馃敟 Exception or Error

No error but tslib is added to dependencies.

馃實 Your Environment


Angular CLI: 7.3.5
Node: 10.15.1
OS: win32 x64
Angular: 7.2.8
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.13.5
@angular-devkit/build-angular      0.13.5
@angular-devkit/build-ng-packagr   0.13.5
@angular-devkit/build-optimizer    0.13.5
@angular-devkit/build-webpack      0.13.5
@angular-devkit/core               7.3.5
@angular-devkit/schematics         7.3.5
@angular/cli                       7.3.5
@ngtools/json-schema               1.1.0
@ngtools/webpack                   7.3.5
@schematics/angular                7.3.5
@schematics/update                 0.13.5
ng-packagr                         4.7.1
rxjs                               6.3.3
typescript                         3.2.4
webpack                            4.29.0

Anything else relevant?
If I understand correctly, tslib is a dependency of Angular and will be installed with it as it is in requires of @angular/core and many other Angular modules. Why would I need to add it manually to my library?

Most helpful comment

tslib is not a dependency of angular itself. But rather a dependency of the TypeScript compiler when you enable TypeScript importHelpers.

Any library that is compiled using importHelpers should always have a direct dependency on tslib and not rely on other libraries to install it.

All 4 comments

I'm sorry, but this issue is not caused by Angular CLI.

See: https://github.com/ng-packagr/ng-packagr/issues/1159

tslib is not a dependency of angular itself. But rather a dependency of the TypeScript compiler when you enable TypeScript importHelpers.

Any library that is compiled using importHelpers should always have a direct dependency on tslib and not rely on other libraries to install it.

Thanks for the super fast clarification!

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings