Open
Description
What version of Ajv are you using? Does the issue happen if you use the latest version?
8.11.0
(currently latest)
Ajv options object
import Ajv from "ajv"
import standaloneCode from "ajv/dist/standalone"
import ajvFormats from "ajv-formats"
const ajv = new Ajv({
code: { esm: true, source: true },
})
ajvFormats(ajv)
const output = standaloneCode(ajv, validate)
JSON Schema
{
"type": "object",
"properties": {
"example": { "type": "number", "format": "int32" }
},
"$schema": "http://json-schema.org/draft-07/schema"
}
Output
// ...
const formats0 = require(`ajv-formats/dist/formats`).fullFormats.int32
// ...
What results did you expect?
// this is kinda awkward, but that's the only way to make it work as of now in pure ESM w/o post-processing
import { fullFormats } from "ajv-formats/dist/formats"
const { int32 } = fullFormats
Are you going to resolve the issue?
I've tried to look into it, but it seems to be coupled with many ajv packages, so please let me know your proposal.
I believe the resolution should be done in multiple steps:
- the
import
should be used instead ofrequire
(this issue) ajv-formats
should export every function separately, not scoped withinfullFormats
,fastFormats
, etc. (Export formats separately, without scoping #65)