import { RawSourceMap, SourceNode } from 'source-map'; import Module from './module'; import Packet from './packet'; import Porter from './porter'; import { LoaderConfig, PartiallyRequired } from './defs'; type WrapOptions = PartiallyRequired; interface BundleOptions { packet: Packet; entries?: string[]; loader?: boolean; format?: '.js' | '.css' | '.wasm'; package?: boolean; all?: boolean; loaderConfig?: LoaderConfig; } interface ObtainOptions { loader?: boolean; minify?: boolean; } export interface CompileOptions { all?: boolean; manifest?: Record; package?: boolean; writeFile?: boolean; } interface ReloadOptions { cause?: Bundle; } interface SourceNodeOptions { source: string; sourceContent: string; code: string; map?: RawSourceMap; } type ScopeType = 'module' | 'packet' | 'all'; export default class Bundle { #private; app: Porter; packet: Packet; parent: Bundle | null; children: Bundle[]; format: '.js' | '.css' | '.wasm'; scope: ScopeType; loader: boolean; loaderConfig?: LoaderConfig; updatedAt: Date | null; static wrap(options: WrapOptions): Bundle[]; static create(options: BundleOptions): Bundle; constructor(options: BundleOptions); /** * Traverse all the bundled modules. Following modules will be skipped over: * - module is just a placeholder object generated by {@link FakePacket} * - module is preloaded but the ancestor isn't one of the preload entry * - module is one of the bundle exceptions */ [Symbol.iterator](): Generator; get entries(): string[]; set entries(files: string[]); get entry(): string; get entryPath(): string; get outkey(): string; get output(): string; get contenthash(): string; get outputPath(): string; createSourceNode({ source, sourceContent, code, map }: SourceNodeOptions): Promise; obtainLoader(loaderConfig: LoaderConfig): Promise<{ source: string; sourceContent: string; code: string; }>; minifyLoader(loaderConfig?: {}): Promise; /** * check if bundle cache is stale * @returns {boolean} */ revalidate(): boolean; reload(options?: ReloadOptions): Promise; _reload({ cause }?: ReloadOptions): Promise; getEntryModule({ minify }?: { minify?: boolean | undefined; }): Promise; obtain(options?: ObtainOptions): Promise<{ code: string; map?: RawSourceMap | undefined; }>; /** * Create a bundle from specified entries */ _obtain({ minify }?: ObtainOptions): Promise<{ code: string; map?: RawSourceMap | undefined; }>; /** * Fuzzy obtain code without source map * @param {Object} options * @param {boolean} options.loader * @param {boolean} options.minify */ fuzzyObtain({ loader, minify }?: ObtainOptions): Promise<{ code: string; }>; exists({ minify }?: { minify?: boolean | undefined; }): Promise; minify(): Promise<{ code: string; map?: RawSourceMap | undefined; }>; /** * Fix source map related settings in both code and map. */ setSourceMap({ code, map }: { code: string; map?: RawSourceMap; }, bundle: Bundle): { code: string; map: RawSourceMap | undefined; }; compile(options: CompileOptions): Promise<{ code: string; map: RawSourceMap | undefined; } | undefined>; } export {};