Problem Statement
Show ESM/CJS interop patterns (default vs named, esModuleInterop, import type).
Explanation
With ESM, prefer `import x, { y } from 'pkg'`. For CommonJS, enable esModuleInterop for default-like imports. Use `import type` to import types only—these vanish at emit, keeping runtime clean.
Code Solution
SolutionRead Only
// ESM style
import http, { request } from 'node:http';
// CJS library with esModuleInterop
import express from 'express'; // ok when enabled
// Type-only import (erased at emit)
import type { Request, Response } from 'express';
// Dynamic import in ESM
const { readFile } = await import('node:fs/promises');