ajv-validator / ajv

The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
https://ajv.js.org
MIT License
13.83k stars 876 forks source link

Standalone esm option `--code-esm` is not recognized #2354

Open nsheff opened 10 months ago

nsheff commented 10 months ago

What version of Ajv are you using? Does the issue happen if you use the latest version?

ajv-cli@5.0.0

The docs say:

pass the --code-esm (CLI) flag if you want ESM exported code.

But when I do this:

ajv compile -s numeric.json --code-esm -o validate_schema.js

It gives this error:

error: parameter --code-esm is unknown

Indeed, in ajv help compile, there is no option listed for --code.esm. So, the documentation here is incorrect: https://ajv.js.org/standalone.html

Maybe related to #2209 -- is ESM module generation not working, and so the CLI option has been removed?

jasoniangreen commented 4 months ago

It looks like this option is simply not supported, but I can see a promising PR that adds it in. I will follow up. https://github.com/ajv-validator/ajv-cli/pull/200

This will either be an enhancement or it's just that the docs are wrong.