Design APIs to provide consistent behavior and user experience across different runtime environments and module systems. Abstract platform-specific differences behind a uniform interface so users don't need to handle environment-specific logic.
Design APIs to provide consistent behavior and user experience across different runtime environments and module systems. Abstract platform-specific differences behind a uniform interface so users don’t need to handle environment-specific logic.
When designing APIs that run on multiple platforms (Node.js, Deno, browsers), ensure that:
process.unref()
in Node vs Deno) are handled internallyFor example, instead of requiring users to call different cleanup methods per platform:
// Bad: Platform-specific API
if (isDeno) {
await esbuild.stop(); // Required in Deno
} else {
// Node handles cleanup automatically
}
// Good: Consistent API
await esbuild.stop(); // Works the same everywhere, with internal platform handling
This approach reduces cognitive load for API consumers and prevents environment-specific bugs in user code.
Enter the URL of a public GitHub repository