arethetypeswrong / arethetypeswrong.github.io

Tool for analyzing TypeScript types of npm packages
https://arethetypeswrong.github.io
MIT License
1.21k stars 41 forks source link

Log where module failures occur #200

Open aryzing opened 2 months ago

aryzing commented 2 months ago

Currently, when attw fails, the error message may look something like,

A require call resolved to an ESM JavaScript file, which is an error in Node and some bundlers. CommonJS consumers will need to use a dynamic import. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/CJSResolvesToESM.md.

The immediate question that comes to mind is: where is the import causing the failure? It would save considerable time and add clarity to the error message if the location of the incorrect module import was logged.

andrewbranch commented 2 months ago

It’s not a require call in the package, it’s a require call of the package. The way attw works is it essentially generates a fake file like

const _ = require("the-pkg")

and sees what happens. I agree the text could be more clear.

aryzing commented 2 months ago

Thank you for clarifying, that makes sense! :facepalm: Happy to close if not going to use the issue for rewording