Can't run api-extractor on library compiled with ivy
See original GitHub issueBug 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
src
directory 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 build
Disable 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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@bgotink Heya, api-extractor 7.17.0 has added support for namespace import bundling. It does however depend on a change to the Angular compiler that is part of #42728 to support the flattened output for these namespace imports, that will be part of next minor release. Consequently, libraries that have been flattened using api-extractor would require an Angular version that is at minimum 12.2 (the next minor), so that may be something to keep in mind.
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.