TS1479
The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import()' call instead.
Broken Code ❌
import { createTempFile } from '@bennycode/utils';
const tempFile = await createTempFile('Hello, World', true);Solution:
To import an ECMAScript module in a CommonJS module, you can use a dynamic import which works asynchronously and returns a Promise.
Fixed Code ✔️
const { createTempFile } = await import('@bennycode/utils');
const tempFile = await createTempFile('Hello, World', true);