.agents/API_DESIGN.md
API design principles for Rspack, focusing on webpack compatibility, versioning, and maintainability.
Prioritize compatibility with webpack's API for seamless migration.
Compatibility Levels:
Goals:
When compatibility conflicts with performance, prioritize performance but provide alternatives.
Examples:
APIs should be type-safe with good TypeScript support.
Guidelines:
any types in public APIsAPIs should be intuitive, well-documented, and provide helpful error messages.
Guidelines:
interface RspackOptions {
entry?: EntryNormalized;
output?: OutputNormalized;
module?: ModuleOptions;
plugins?: RspackPluginInstance[];
}
Principles:
interface Plugin {
apply(compiler: Compiler): void;
name?: string;
}
Principles:
function loader(
this: LoaderContext,
content: string | Buffer,
sourceMap?: SourceMap,
): string | Buffer | void;
Principles:
thiscompiler.hooks.done.tap('PluginName', (stats) => {
// Handle completion
});
Principles:
Follow Semantic Versioning:
Only in major versions, carefully planned.
Types:
Migration Path:
Process:
@deprecated tagTimeline:
Levels:
Checks:
Breaking Changes:
Non-Breaking Changes:
Guidelines:
@internal tag for internal APIsexport type for type-only exportsRequired:
Required:
Plugins can:
Loaders can:
When adding hooks:
Common Issues: