Skip to content

ngc emits JS for Typescript vendor files #20115

Closed
@filipesilva

Description

@filipesilva

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

ngc will emit JavaScript files for vendor TypeScript files imported by the user app, even if these files are not part of the files included by tsconfig.

Expected behavior

Files that are not included in tsconfig should not be compiled.

Minimal reproduction of the problem with instructions

git clone https://github.com/filipesilva/bad-vendor-ngc
cd bad-vendor-ngc
npm i
npm run ngc

After the ngc compilation is finished, you can see non-factory JS files emitted for the angular2-click-outside library:

$ ls -lha out-tsc/app/node_modules/angular2-click-outside/
total 25K
drwxr-xr-x 1 kamik 197609    0 Nov  2 17:20 .
drwxr-xr-x 1 kamik 197609    0 Nov  2 17:20 ..
-rw-r--r-- 1 kamik 197609 1.3K Nov  2 17:20 clickOutside.directive.js
-rw-r--r-- 1 kamik 197609  761 Nov  2 17:20 clickOutside.directive.js.map
-rw-r--r-- 1 kamik 197609  782 Nov  2 17:20 clickOutside.directive.metadata.json
-rw-r--r-- 1 kamik 197609  197 Nov  2 17:20 clickOutside.directive.ngfactory.js.map
-rw-r--r-- 1 kamik 197609 1.5K Nov  2 17:20 clickOutside.directive.ngsummary.json

This library was published with TS files, and without metadata:

$ ls -lha node_modules/angular2-click-outside/
total 295K
drwxr-xr-x 1 kamik 197609    0 Nov  2 17:16 .
drwxr-xr-x 1 kamik 197609    0 Nov  2 17:16 ..
drwxr-xr-x 1 kamik 197609    0 Nov  2 17:16 .idea
-rw-r--r-- 1 kamik 197609   21 May 15  2016 .npmignore
-rw-r--r-- 1 kamik 197609    3 May 15  2016 .nvmrc
-rw-r--r-- 1 kamik 197609  282 Aug 19  2016 clickOutside.directive.d.ts
-rw-r--r-- 1 kamik 197609 2.8K Aug 19  2016 clickOutside.directive.js
-rw-r--r-- 1 kamik 197609 1.5K Aug 19  2016 clickOutside.directive.js.map
-rw-r--r-- 1 kamik 197609  682 Aug 19  2016 clickOutside.directive.ts
-rw-r--r-- 1 kamik 197609  601 May 15  2016 gulpfile.js
-rw-r--r-- 1 kamik 197609   66 Aug 19  2016 index.d.ts
-rw-r--r-- 1 kamik 197609  476 Aug 19  2016 index.js
-rw-r--r-- 1 kamik 197609  113 Aug 19  2016 index.js.map
-rw-r--r-- 1 kamik 197609   64 May 15  2016 index.ts
-rw-r--r-- 1 kamik 197609 1.5K May 15  2016 LICENSE
-rw-r--r-- 1 kamik 197609 1.7K Nov  2 17:16 package.json
-rw-r--r-- 1 kamik 197609  368 May 16  2016 README.md
-rw-r--r-- 1 kamik 197609  368 May 15  2016 tsconfig.json
-rw-r--r-- 1 kamik 197609   96 May 15  2016 typings.json

What is the motivation / use case for changing the behavior?

This behaviour is problematic because it hides improperly packaged libraries, and may fail compilation due to the app TS version being different from the TS version needed by the library.

Environment


Angular version: 5.0.0


Browser:
- [ ] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX   6.11.1
- Platform:   Windows

Others:

Related to angular/angular-cli#8263, angular/angular-cli#8216.

/cc @chuckjaz

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions