///
import { AcceptedPlugin, Processor } from 'postcss';
import Packet, { PacketMeta } from './packet';
import Module from './module';
import Bundle, { CompileOptions } from './bundle';
import Cache from './cache';
import { MinifyOptions } from 'uglify-js';
import { ImportOption } from './named_import';
interface FallbackOptions {
[key: string]: string | false;
}
type ReadResult = [Buffer | Record | string, Record] | null | undefined;
interface ParseOptions {
loader: boolean;
}
interface PorterOptions {
root?: string;
paths?: string | string[];
entries?: string[];
preload?: string[];
lazyload?: string[];
cache?: {
path: string;
clean: boolean;
};
output?: {
path?: string;
};
transpile?: {
include?: string[];
typescript?: 'tsc' | 'babel' | 'swc';
};
bundle?: {
exclude?: string[];
};
resolve?: {
import?: ImportOption[];
alias?: Record;
fallback?: FallbackOptions;
suffixes?: string[];
};
source?: {
serve?: boolean;
inline?: boolean;
root?: string;
};
map?: Record;
lessOptions?: Record;
uglifyOptions?: MinifyOptions & {
keep_fnames: RegExp;
};
postcssPlugins?: AcceptedPlugin[];
baseUrl?: string;
lock?: Record;
package?: PacketMeta;
/**
* transform javascript and typescript with swc or not, disabled by default
*/
swc?: boolean;
}
declare class Porter {
#private;
moduleCache: Record;
packetCache: Record;
parseCache: Record | null>;
packet: Packet;
root: string;
baseUrl: string;
map?: Record;
timeout: number;
entries: string[];
preload: string[];
lazyload: string[];
source: {
serve: boolean;
inline: boolean;
root: string;
mappingURL?: string;
};
cache: Cache;
output: {
clean: boolean;
path: string;
};
bundle: {
exclude: string[];
exists?: (bundle: Bundle) => Promise;
};
transpile: {
include: string[];
typescript: string;
};
resolve: {
import?: ImportOption[];
fallback: FallbackOptions;
suffixes: string[];
};
cssTranspiler: Processor;
lessOptions?: Record;
uglifyOptions?: Record;
browsers: string[];
browserslistrc?: string;
targets?: {
[key: string]: number;
};
lock?: Record;
swc: boolean;
constructor(opts: PorterOptions);
ready(options?: {
minify: boolean;
}): any;
readFilePath(fpath: string | null): Promise<[string | Buffer, Record] | undefined>;
readBuiltinJs(name: string): Promise<[string | Buffer, Record] | undefined>;
pack({ minify }?: {
minify?: boolean | undefined;
}): Promise;
reload(): Promise;
prepareFiles(files: string[], isEntry?: boolean): Promise[];
get lazyloads(): Set;
prepare({ minify }?: {
minify?: boolean | undefined;
}): Promise;
compilePackets(opts: CompileOptions): Promise;
compileExclusivePackets(opts: CompileOptions): Promise;
compileAll({ entries }: {
entries: string[];
}): Promise;
compileEntry(entry: string, opts: CompileOptions): Promise;
readRawFile(file: string): Promise<[string | Buffer, Record] | undefined>;
parseId(id: string, options?: ParseOptions): Promise;
_parseId(id: string, { loader }?: {
loader?: boolean | undefined;
}): Promise;
readCss(outputPath: string): Promise;
readJs(outputPath: string, query: Record): Promise;
readMap(mapPath: string): Promise;
readWasm(outputPath: string): Promise;
readFile(file: string, query: Record): Promise;
destroy(): Promise;
func(): (req: any, res: any, next: () => {}) => {} | undefined;
gen(): (this: any, next: GeneratorFunction) => any;
async(): (ctx: any, next: () => Promise) => Promise;
}
export default Porter;