-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Description
Bug Report
Affected Package
The issue is caused by package @angular/compiler-cli
Is this a regression?
No, though I should note this is only an issue with Ivy and not with ViewEngine.
Description
The .d.ts file generated by a partial ivy compilation is not compatible with @microsoft/api-extractor, a tool preferred by the APF document
As of APF v8 we now prefer to run the .d.ts bundler tool from https://api-extractor.com/ so that the entire API appears in a single file.
In prior APF versions each entry point would have a
srcdirectory next to the .d.ts entry point and this directory contained individual d.ts files matching the structure of the original source code. While this distribution format is still allowed and supported, it is highly discouraged because it confuses tools like IDEs that then offer incorrect autocompletion, and allows users to depend on deep-import paths which are typically not considered to be public API of a library or a package.
While this isn't a bug in an angular package per se, the advise given in the APF document has pushed me towards opening this ticket as bug on the angular/angular repo and not as feature in microsoft/rushstack.
Minimal Reproduction
cd $(mktemp -d)
git clone github.com/bgotink/angular-repro-42063 .
yarn
yarn buildDisable enableIvy in the tsconfig.json file and yarn build will work.
Exception or Error
Error while running api-extractor:
ERROR: "import * as ___ from ___;" is not supported yet for local files.
/private/var/folders/_d/ch2kc4h960d10cy_2c41qqzw0000gn/T/tmp.6Rkk9EFSAa/dist/module.d.ts:3:1
The dist/module.d.ts file the error points to:
import { MyDirective } from './directive';
import * as i0 from "@angular/core";
import * as i1 from "./directive";
export declare class MyModule {
static ɵfac: i0.ɵɵFactoryDeclaration<MyModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MyModule, [typeof i1.MyDirective], never, [typeof i1.MyDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<MyModule>;
}
export { MyDirective };
Your Environment
Angular Version:
@angular/* version 12.0.0-rc.3, ng-packagr version 12.0.0-rc.3, @microsoft/api-extractor version 7.15.1
Anything else relevant?
We don't actually use ng-packagr. Our (private) toolchain yields the exact same output so I used ng-pacakgr for the reproduction.
We follow the APF document's preference and run @microsoft/api-extractor to roll up the .d.ts files.