mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Instead of relying on Microsoft's API extractor for `d.ts` bundling, we are switching to Rollup-based `.d.ts` bundling. This allows us to support code spliting, even for `.d.ts` files, allowing for relative imports to be used between entry-points, without ending up duplicating `.d.ts` definitions in two files. This would otherwise cause problems with assignability of types. It also nicely integrates into our existing rollup configuration, and overall simplifies the `ng_package` rule even further! Notably `tsup` also uses this rollup plugin, and it seems to work well. Keep in mind that Microsoft's API extractor is pretty hard to integrate, caused many problems in the past, and isn't capable of code splitting. This aligns our d.ts bundling with the .mjs bundling (great alignment). PR Close #60321 PR Close #60332
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.dev/license
|
|
*/
|
|
|
|
/**
|
|
* Interface describing a file captured in the Bazel action.
|
|
* https://docs.bazel.build/versions/main/skylark/lib/File.html.
|
|
*/
|
|
export interface BazelFileInfo {
|
|
/** Execroot-relative path pointing to the file. */
|
|
path: string;
|
|
/** The path of this file relative to its root. e.g. omitting `bazel-out/<..>/bin`. */
|
|
shortPath: string;
|
|
}
|
|
|
|
/** Interface describing an entry-point. */
|
|
export interface EntryPointInfo {
|
|
/** ES2022 index file for the APF entry-point. */
|
|
index: BazelFileInfo;
|
|
/** Entry-point type definition file for the APF entry-point (unbundled). */
|
|
typingsEntryPoint: BazelFileInfo;
|
|
|
|
/** Relative path to flat ES2022 ES module bundle file. */
|
|
fesm2022RelativePath: string;
|
|
/** Relative path to the dts bundle for the entry-point. */
|
|
dtsBundleRelativePath: string;
|
|
|
|
/**
|
|
* Whether the index or typing paths have been guessed. For entry-points built
|
|
* through `ts_library`, there is no explicit setting that declares the entry-point
|
|
* so the index file is guessed.
|
|
*/
|
|
guessedPaths: boolean;
|
|
}
|
|
|
|
/** Interface capturing relevant metadata for packaging. */
|
|
export interface PackageMetadata {
|
|
/** NPM package name of the output. */
|
|
npmPackageName: string;
|
|
/** Record of entry-points (including the primary one) and their info. */
|
|
entryPoints: Record<string, EntryPointInfo>;
|
|
/**
|
|
* Path to the Rollup FESM bundle output directory, containing all FESM
|
|
* bundles and shared chunks.
|
|
*/
|
|
fesmBundlesOut: BazelFileInfo;
|
|
/**
|
|
* Path to the Rollup dts bundle output directory, containing all `d.ts`
|
|
* bundles and shared chunks.
|
|
*/
|
|
dtsBundlesOut: BazelFileInfo;
|
|
}
|