Bug Report
π Search Terms
NodeNext, esm, CJS, cli-spinners
π Version & Regression Information
- This only occurs in nightly builds.
- I was unable to test this on prior versions because
nodenext is only supported in the nightly versions.
β― Playground Link
From what I can tell you can't install npm modules in the playground, so I made a repro on StackBlitz: https://stackblitz.com/edit/node-opvt9e?file=index.ts run npm run typecheck in the console to see the issue.
π» Code
import spinners from 'cli-spinners';
console.log(spinners);
π Actual behavior
TypeScript cannot find the typings for cli-spinners which is a CJS module. It does not use a main or exports or types field in the package.json, it just includes a index.js and index.d.ts file.
index.ts:1:22 - error TS2307: Cannot find module 'cli-spinners' or its corresponding type declarations.
1 import spinners from 'cli-spinners';
~~~~~~~~~~~~~~
Found 1 error in index.ts:1
π Expected behavior
New NodeNext module behaviour to import CJS as it used to. E.g looking at index.d.ts if there is no main field. https://www.typescriptlang.org/docs/handbook/module-resolution.html#how-typescript-resolves-modules
πͺ Related
Bug Report
π Search Terms
NodeNext, esm, CJS, cli-spinners
π Version & Regression Information
nodenextis only supported in the nightly versions.β― Playground Link
From what I can tell you can't install npm modules in the playground, so I made a repro on StackBlitz: https://stackblitz.com/edit/node-opvt9e?file=index.ts run
npm run typecheckin the console to see the issue.π» Code
π Actual behavior
TypeScript cannot find the typings for
cli-spinnerswhich is a CJS module. It does not use amainorexportsortypesfield in thepackage.json, it just includes aindex.jsandindex.d.tsfile.π Expected behavior
New
NodeNextmodule behaviour to import CJS as it used to. E.g looking atindex.d.tsif there is nomainfield. https://www.typescriptlang.org/docs/handbook/module-resolution.html#how-typescript-resolves-modulesπͺ Related
mainfieldΒ sindresorhus/cli-spinners#61