@tsdi/pack
Version:
@tsdi/pack is simple build tasks, base on AOP, Ioc container, via @tsdi. dev build pack activities.
252 lines (251 loc) • 6.46 kB
TypeScript
import { AfterInit, Binding } from '@tsdi/components';
import { TemplateOption, Src, IActivityContext, Expression } from '@tsdi/activities';
import { CompilerOptions } from 'typescript';
import { ExternalOption, RollupCache, WatcherOptions, GlobalsOption, Plugin, RollupOptions } from 'rollup';
import { PlatformService } from '../PlatformService';
/**
* target type.
*/
export declare type TargetType = 'es3' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'esnext' | 'json' | 'latest';
/**
* module type.
*/
export declare type ModuleType = 'commonjs' | 'amd' | 'umd' | 'system' | 'es2015' | 'es2020' | 'es2022' | 'esnext' | 'node12' | 'nodenext';
/**
* lib bundle option.
*/
export interface LibBundleOption {
/**
* typescript Compiler option target.
*
* @type {TargetType}
* @memberof LibBundleOption
*/
target?: TargetType;
/**
* typescript Compiler options module.
*/
module?: ModuleType;
targetFolder?: string;
/**
* default `index.js`
*
* @type {string}
* @memberof LibBundleOption
*/
main?: string;
/**
* for package typings
*
* @type {string}
* @memberof LibTaskOption
*/
dtsMain?: string;
/**
* module name output for package.
*
* @type {string}
* @memberof LibTaskOption
*/
moduleName?: string | string[];
/**
* output module folder name in outdir path. default use module name as folder name.
*
* @type {string}
* @memberof LibTaskOption
*/
moduleFolder?: string;
annotation?: boolean;
uglify?: boolean;
tsconfig?: string | CompilerOptions;
/**
* rollup input.
*
* @type {Src>>}
* @memberof LibTaskOption
*/
input?: Src;
/**
* the file name (with out dir path) rollup to write, or main file name.
*
* @type {string>}
* @memberof LibTaskOption
*/
outputFile?: string;
/**
* rollup format option.
*
* @type {string>}
* @memberof LibTaskOption
*/
format?: string;
}
export interface LibPackBuilderOption extends TemplateOption {
/**
* tasks
*
* @type { Binding<LibBundleOption[]>}
* @memberof LibPackBuilderOption
*/
bundles: Binding<LibBundleOption[]>;
/**
* project source.
*
* @type {Binding<string>}
* @memberof LibPackBuilderOption
*/
src: Binding<Src>;
/**
* project out dir.
*
* @type {Binding<string>}
* @memberof LibPackBuilderOption
*/
outDir: Binding<string>;
/**
* annotation source file.
*
* @type {Binding<boolean>}
* @memberof LibPackBuilderOption
*/
annotation?: Binding<boolean>;
/**
* dts sub folder name
*
* @type {string}
* @memberof LibTaskOption
*/
dts?: Binding<string>;
/**
* enable source maps or not.
*
* @type {Binding<boolean|string>}
* @memberof RollupOption
*/
sourcemap?: Binding<boolean | string>;
test?: Binding<Src>;
/**
* rollup external setting.
*
* @type {NodeExpression<ExternalOption>}
* @memberof RollupOption
*/
external?: Binding<ExternalOption>;
/**
* custome config all rollup plugins.
*
* @type {NodeExpression<Plugin[]>}
* @memberof RollupOption
*/
plugins?: Binding<Plugin[]>;
cache?: Binding<RollupCache>;
watch?: Binding<WatcherOptions>;
globals?: Binding<GlobalsOption>;
/**
* custom setup rollup options.
*
* @type {(RollupOptions)}
* @memberof RollupOption
*/
options?: Binding<RollupOptions>;
/**
* external Libs for auto create rollup options.
*
* @type {string[]}
* @memberof LibBundleOption
*/
externalLibs?: Binding<string[]>;
/**
* include libs for auto create rollup options.
*
* @type {Binding<string[]>}
* @memberof LibPackBuilderOption
*/
includeLib?: Binding<string[]>;
/**
* use this plugins before auto generate plugins.
*
* resolveId
* ` (source: string, importer: string) => string | false | null | {id: string, external?: boolean, moduleSideEffects?: boolean | null}`
*
* @type { Binding<Plugin[]>;}
* @memberof LibPackBuilderOption
*/
beforeResolve?: Binding<Plugin[]>;
/**
* replaces
*/
replaces?: string[][];
}
export declare class LibPackBuilder implements AfterInit {
protected platform: PlatformService;
constructor();
src: Src;
test: Src;
/**
* tasks
*
* @type {(LibBundleOption[])}
* @memberof LibPackBuilderOption
*/
bundles: LibBundleOption[];
outDir: string;
annotation: boolean;
dts: string;
/**
* rollup external setting.
*
* @type {ExternalOption}
* @memberof RollupOption
*/
external?: Expression<ExternalOption>;
externalLibs: string[];
includeLib: string[];
/**
* rollup plugins setting.
*
* @type {Plugin[]}
* @memberof RollupOption
*/
plugins: Plugin[];
globals: GlobalsOption;
cache?: RollupCache;
watch?: WatcherOptions;
replaces: string[][];
/**
* custom setup rollup options.
*
* @type {(NodeExpression<RollupOptions>)}
* @memberof RollupOption
*/
options?: RollupOptions;
sourcemap?: boolean | string;
beforeResolve: Plugin[];
toOutputPath(...mdpath: string[]): string;
toModulePath(input: LibBundleOption, ...paths: string[]): string;
getTargetPath(input: LibBundleOption): string;
getTargetFolder(input: LibBundleOption): string;
getModuleFolder(input: LibBundleOption): string;
transRollupInput(input: LibBundleOption): string | string[];
transRollupoutput(input: LibBundleOption): {
format: string;
file: string;
dir: string;
};
transCompileOptions(input: LibBundleOption): {
target: TargetType;
module: ModuleType;
} | {
target: TargetType;
module?: undefined;
} | {
target?: undefined;
module?: undefined;
};
getDtsPath(input: LibBundleOption): string;
transPlugins(ctx: IActivityContext): any[];
getBundleSrc(input: LibBundleOption): string;
json(json: any, input: any): any;
onAfterInit(): Promise<void>;
static ρAnn(): any;
}