Fix types for NodeNext
What issue does this pull request resolve?
Closes #2132
What changes did you make?
Changed the way types are exported to improve support for users module: node16/nodenext users.
Is there anything that requires more attention while reviewing?
@epoberezkin I think this is ready for review now, and I'm now just hitting the node 14 build issue plaguing the main branch. Maybe we can disable now that node 14 is EOL?
Okay yep this is ready. You can see the build passing on the other builds in https://github.com/ajv-validator/ajv/pull/2365/commits/b7b5fd0861baa89d702d7d36e01c0a76eb4b50c3, where the only change I did was temporarily remove 14 from the matrix.
Pushed more updates + confirmed the build pass without node 14
Thanks @jasoniangreen! Let me know if you have feedback on this PR — would love to move this forward
Thanks @jasoniangreen! Let me know if you have feedback on this PR — would love to move this forward
Let me update your branch with master and have a look.
Something that hasn't been considered with this change is the browser bundles we generate. With this PR the rollup command, which is used to generate browser bundles, doesn't work. Also there are a lot of changes in this PR, and after speaking to epoberezkin there is not a lot appetite for such a large change to resolve this, at least not at this time. He has asked me to explore some alternatives, possible based on this work around.
Either way we have to be wary of the various exports and ways that AJV is used and ensure we don't make life difficult for a lot of people by changing things unnecessarily.
That's totally fair! Would you consider just adding named exports for the classes alongside the default exports? The main pain point is the default exports. If people have the named exports as an alternative, I think that would satisfy most folks, even if it means the default exports are left clunky.
Opened #2389, which is much smaller. NodeNext users can switch to using the named export instead, side-stepping the default import/export issues.
Closing in favor of #2389