Ng-packagr: Interface imports are not removed from JavaScript output

Created on 3 Mar 2020  路  3Comments  路  Source: ng-packagr/ng-packagr

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

If I have a file that contains both a service and an interface for example, eg:

@Injectable({ providedIn: 'root' })
export class ResizeService {
    ...
}

export interface ResizeDimensions {
    width: number;
    height: number;
}

And in another file I have an import such as:

import { ResizeDimensions, ResizeService } from './resize.service';

I receive warnings like:

WARNING: Non-existent export 'ResizeDimensions' is imported from dist\library\esm5\directives\resize\index.js

Also when looking at the esm5 & esm2015 output the interface import is still present, even though the interface itself has obviously been removed as part of the TypeScript compilation.

How To Reproduce

I have created a repro repo: https://github.com/ashley-hunter/ng-packagr-warnings

To see the issue simply run: ng build sample-lib --prod

You will see the following output:

Building Angular Package

------------------------------------------------------------------------------
Building entry point 'sample-lib'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
Bundling to FESM2015
WARNING: Non-existent export 'SampleLibModel' is imported from dist/sample-lib/esm2015/lib/sample-lib.service.js
Bundling to FESM5
WARNING: Non-existent export 'SampleLibModel' is imported from dist/sample-lib/esm5/lib/sample-lib.service.js
Bundling to UMD
Minifying UMD bundle
Writing package metadata
Built sample-lib

Expected Behaviour

Interface imports should not be present in the JavaScript output and the warning messages should not appear in console.

Version Information

ng-packagr:            9.0.2
@angular/compiler:     9.0.4
rollup:                1.31.1
tsickle:               
typescript:            3.7.5

Thanks!

bug

Most helpful comment

Confirmed as broken. Traced to here:

https://github.com/ng-packagr/ng-packagr/blob/0e414cecd8a386b426a0147d4d0688043e6d6e87/src/lib/ts/ctor-parameters.ts#L314-L317

This should only create clones when importSymbol.flags & ts.SymbolFlags.Value is true, or, alternatively, the parameterTypeSymbols should only be populated with value symbols.

All 3 comments

Confirmed as broken. Traced to here:

https://github.com/ng-packagr/ng-packagr/blob/0e414cecd8a386b426a0147d4d0688043e6d6e87/src/lib/ts/ctor-parameters.ts#L314-L317

This should only create clones when importSymbol.flags & ts.SymbolFlags.Value is true, or, alternatively, the parameterTypeSymbols should only be populated with value symbols.

As of #1663 this should have been resolved, as constructor downleveling has moved into ngc.

This will only be fixed in 10.0 though, as the Angular compiler only performs the downleveling since v10.

Be aware that switching library compilation to ng-packagr 10 once it's out of RC may have impact on consumer apps that are still on Angular 9, as there is no guaranteed forwards compatibility with libraries compiled with Angular 10. I am not aware of potential incompatibilities at the moment, but nothing is guaranteed here.

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

_This action has been performed automatically by a bot._

Was this page helpful?
5 / 5 - 1 ratings