Design APIs with dependency implications in mind. Carefully consider how your API design choices might force dependencies on consumers, which can lead to dependency bloat or tight coupling between components.
Design APIs with dependency implications in mind. Carefully consider how your API design choices might force dependencies on consumers, which can lead to dependency bloat or tight coupling between components.
When designing APIs that bridge between different modules or layers:
Example: Instead of forcing all components to depend on a specific implementation:
// Avoid: Forces napi dependency on all consumers
#[napi(object)]
struct EventObject {
type_name: String,
severity: String,
message: String
}
// Better: Uses generic interfaces without dependency leakage
pub fn emit_compilation_event<T: CompilationEvent>(event: T) {
turbo_tasks().emit_compilation_event(Arc::new(event));
}
This approach allows functionality to be used without requiring direct dependencies on implementation details, keeping your architecture more flexible and maintainable.
Enter the URL of a public GitHub repository