You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Use the AJV codeoption to decide if the standalone code generator would emit CJS (require/module) or ESM (import/export) instead of hardcoding require and module.exports as shown below in the standalone.js file
Typescript and ESM users will have to go through some build system configurations to resolve the require in ESM runtime headache during development. Especially that the StandaloneValidator from the @fastify/ajv-compiler package respects the ESM AJV option out of the box.
If we can leverage the serializerOptions, Fastify users in ESM envirmenment can easily use a standalone serializers with the AJV options
ajv: {
code: { source: true, esm: true }
}
Example
No response
The text was updated successfully, but these errors were encountered:
mouhannad-sh
changed the title
emit CJS/EMS syntax in standalone mode based on AJV code options
emit CJS/ESM syntax in standalone mode based on AJV code options
Feb 13, 2024
Prerequisites
🚀 Feature Proposal
Use the AJV
code
option to decide if the standalone code generator would emit CJS (require/module
) or ESM (import/export
) instead of hardcodingrequire
andmodule.exports
as shown below in thestandalone.js
filefast-json-stringify/lib/standalone.js
Lines 14 to 23 in 74c35c0
Motivation
Typescript and ESM users will have to go through some build system configurations to resolve the
require
in ESM runtime headache during development. Especially that theStandaloneValidator
from the@fastify/ajv-compiler
package respects the ESM AJV option out of the box.If we can leverage the serializerOptions, Fastify users in ESM envirmenment can easily use a standalone serializers with the AJV options
Example
No response
The text was updated successfully, but these errors were encountered: