You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typescript clients using "moduleResolution": "nodenext" with "module": "commonjs" should be able to import the package. I have a large monorepo with a mix of CommonJS and ESM modules, and want to use Node 16+ module resolution across the monorepo.
Actual Behavior
Typescript is unable to import the file, with error:
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("@puppeteer/replay")' call instead.
To convert this file to an ECMAScript module, change its file extension to '.mts', or add the field `"type": "module"` to 'puppeteer-client/package.json'.ts
Expected Behavior
Typescript clients using
"moduleResolution": "nodenext"
with"module": "commonjs"
should be able to import the package. I have a large monorepo with a mix of CommonJS and ESM modules, and want to use Node 16+ module resolution across the monorepo.Actual Behavior
Typescript is unable to import the file, with error:
The issue is discussed here: microsoft/TypeScript#50466
Steps to Reproduce the Problem
npm i
npm run build
The repository is very simple, and the main trigger is the
tsconfig.json
below:Fix
The fix is to provide a separate type file
cjs/main.d.cts
for the.cjs
CommonJS module, and refer to that inpackage.json
:I'll submit a PR for this change.
Specifications
The text was updated successfully, but these errors were encountered: