Bundle management functionality for combining metadata from multiple modules into flat module bundles and generating index files for library packaging.
Core class that bundles metadata from multiple modules into a single bundled module structure.
/**
* Bundles metadata from multiple modules into a single flat module
*/
class MetadataBundler {
/**
* Creates a metadata bundler
* @param root - Root module path for bundling
* @param importAs - Optional import name for the bundle
* @param host - Host for resolving module metadata (required)
*/
constructor(root: string, importAs: string | undefined, host: MetadataBundlerHost);
/**
* Creates a bundled metadata structure from multiple modules
* @returns Bundled module containing all metadata
*/
getMetadataBundle(): BundledModule;
}Usage Example:
import { MetadataBundler, MetadataBundlerHost } from "@angular/tsc-wrapped";
const host: MetadataBundlerHost = {
getMetadataFor: (moduleName: string) => {
// Return metadata for the specified module
return loadMetadataFromFile(moduleName);
},
resolveModule: (moduleName: string, containingFile: string) => {
// Resolve module path
return require.resolve(moduleName);
}
};
const bundler = new MetadataBundler("./src/public_api", "my-library", host);
const bundle = bundler.getMetadataBundle();Interface defining the host capabilities required by the metadata bundler.
/**
* Host interface for metadata bundler operations
*/
interface MetadataBundlerHost {
/**
* Get metadata for a specific module
* @param moduleName - Name of the module to get metadata for
* @returns Module metadata
*/
getMetadataFor(moduleName: string): ModuleMetadata;
}Adapter that implements MetadataBundlerHost using a TypeScript compiler host.
/**
* Adapter that bridges TypeScript compiler host to metadata bundler host
*/
class CompilerHostAdapter implements MetadataBundlerHost {
/**
* Creates a compiler host adapter
* @param host - TypeScript compiler host to adapt
*/
constructor(host: ts.CompilerHost);
getMetadataFor(moduleName: string): ModuleMetadata;
}Usage Example:
import { CompilerHostAdapter, MetadataBundler } from "@angular/tsc-wrapped";
import * as ts from "typescript";
const compilerHost = ts.createCompilerHost({});
const bundlerHost = new CompilerHostAdapter(compilerHost);
const bundler = new MetadataBundler("./src/index", "my-lib", bundlerHost);
const bundle = bundler.getMetadataBundle();The main structure representing a bundled module with all its metadata.
/**
* Structure representing a bundled module
*/
interface BundledModule {
/** Module metadata */
metadata: ModuleMetadata;
/** Private symbol entries that need special handling */
privates: BundlePrivateEntry[];
}Map structure for bundle entry metadata.
/**
* Map of bundle entries
*/
interface BundleEntries {
[name: string]: MetadataEntry;
}Structure for private symbols that are bundled but not publicly exported.
/**
* Entry for private symbols in bundles
*/
interface BundlePrivateEntry {
/** Private symbol name */
privateName: string;
/** Original symbol name */
name: string;
/** Module where the symbol is defined */
module: string;
}Utility function for generating index file content from private bundle entries.
/**
* Generates index file content from private bundle entries
* @param index - Base index content
* @param privates - Array of private entries to add to index
* @returns Generated index file content
*/
function privateEntriesToIndex(index: string, privates: BundlePrivateEntry[]): string;Usage Example:
import { privateEntriesToIndex } from "@angular/tsc-wrapped";
const baseIndex = "export * from './public_api';";
const privateEntries = [
{
privateName: "ɵInternalService",
name: "InternalService",
module: "./internal/service"
}
];
const generatedIndex = privateEntriesToIndex(baseIndex, privateEntries);
console.log("Generated index:", generatedIndex);Type for static member metadata in bundled modules.
/**
* Type for static metadata information
*/
type StaticsMetadata = {[name: string]: MetadataValue};