Missing information when using --checkFeatures
Requested Update
If running es-check es2017 --checkFeatures detects an unsupported feature it does not output the erroring file and line number:
es-check es2017 *.min.js --checkFeatures
/path/to/node_modules/es-check/detectFeatures.js:71
throw new Error(
^
Error: Unsupported features detected: ErgonomicBrandChecks, ArrayPrototypeAt. These require a higher ES version than 8.
at detectFeatures (/path/to/node_modules/es-check/detectFeatures.js:71:11)
at /path/to/node_modules/es-check/index.js:222:54
at Array.forEach (<anonymous>)
at Command.<anonymous> (/path/to/node_modules/es-check/index.js:203:19)
at Command.listener [as _actionHandler] (/path/to/node_modules/commander/lib/command.js:542:17)
at /path/to/node_modules/commander/lib/command.js:1502:14
at Command._chainOrCall (/path/to/node_modules/commander/lib/command.js:1386:12)
at Command._parseCommand (/path/to/node_modules/commander/lib/command.js:1501:27)
at Command.parse (/path/to/node_modules/commander/lib/command.js:1064:10)
at Object.<anonymous> (/path/to/node_modules/es-check/index.js:256:9)
Node.js v20.9.0
Why Is This Update Needed?
When running es-check on a list of files defined by a glob (as done in the example above), it does not become clear where the unsupported feature is located.
Compared to the output of a “ES version matching error”:
❯ yarn es-check es2017 *.min.js
error: ES-Check: there were 1 ES version matching errors.
info:
ES-Check Error:
----
· erroring file: path/to/file.min.js
· error: SyntaxError: Unexpected token (3:12)
· see the printed err.stack below for context
----
SyntaxError: Unexpected token (3:12)
at pp$4.raise (/path/to/node_modules/acorn/dist/acorn.js:3646:15)
at pp$9.unexpected (/path/to/node_modules/acorn/dist/acorn.js:772:10)
at pp$5.parseIdentNode (/path/to/node_modules/acorn/dist/acorn.js:3582:12)
at pp$5.parseIdent (/path/to/node_modules/acorn/dist/acorn.js:3554:21)
at pp$5.parsePropertyName (/path/to/node_modules/acorn/dist/acorn.js:3373:111)
at pp$5.parseProperty (/path/to/node_modules/acorn/dist/acorn.js:3296:10)
at pp$5.parseObj (/path/to/node_modules/acorn/dist/acorn.js:3259:23)
at pp$5.parseExprAtom (/path/to/node_modules/acorn/dist/acorn.js:2961:19)
at pp$5.parseExprSubscripts (/path/to/node_modules/acorn/dist/acorn.js:2769:21)
at pp$5.parseMaybeUnary (/path/to/node_modules/acorn/dist/acorn.js:2727:19)
Are There Examples Of This Requested Update Elsewhere?
:shrug:
Read about references issues here. Provide paragraph text responses to each header.
Hello @p3k! Thanks for the issue!
Why can't the people make updates on based on the error using find & replace? es-check was built (almost a decade ago) to fail fast—after linting & babel transpilation. I still initially feel like linting and transpilation tools are better suited for line-by-line fixes...?
@yowainwright Apart from the inconvenience to find out which feature caused the error in which file, it looks like an inconsistency to get information about filename and line number in one case but only a stack trace in another.
Thanks! I agree that the error logs for the new --checkFeatures should be improved to include the file, and needs to be improved. 🙏
Would it be possible to provide the list of unsupported features in a machine-readable format? This way one could use es-check to automatically bundle the needed polyfills:
$ es-check es2017 /path/to/bundle.min.js --check-features --format json
["ErgonomicBrandChecks", "ArrayPrototypeAt"]
I noticed this too and my first thought was that es-check had an error in itself before I understood what was going on.
I updated the output in the recent build thanks to this feedback. Please (at) me and re-open if more similar updates are desired.
add information when using --checkFeatures, when it update? i need this ability. Thanks!
@caomeibuaichibaicai are you getting better insights with latest or no? ~Thanks!