From fdf7e70dc3ad389dd6e27f653a10674adb33f3b8 Mon Sep 17 00:00:00 2001 From: MohammadHasan Akbari Date: Sat, 13 Jul 2024 04:49:25 +0330 Subject: [PATCH] chore: backward compatibility --- lib/standalone/index.ts | 2 +- spec/ajv.ts | 1 + spec/ajv2019.ts | 1 + spec/ajv2020.ts | 1 + spec/ajv_jtd.ts | 1 + spec/standalone.spec.ts | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/standalone/index.ts b/lib/standalone/index.ts index 786a4afd5c..47a2a3bb4c 100644 --- a/lib/standalone/index.ts +++ b/lib/standalone/index.ts @@ -34,7 +34,7 @@ function standaloneCode( // Always do named export as `validate` rather than the variable `n` which is `validateXX` for known export value return `"use strict";${_n}export const validate = ${n};${_n}export default ${n};${_n}${vCode}` } - return `"use strict";${_n}module.exports = ${n};${_n}module.exports.Ajv = ${n};${_n}${vCode}` + return `"use strict";${_n}module.exports = ${n};${_n}module.exports.default = ${n};${_n}module.exports.Ajv = ${n};${_n}${vCode}` } function multiExportsCode( diff --git a/spec/ajv.ts b/spec/ajv.ts index 6628bbd36c..8a1a586969 100644 --- a/spec/ajv.ts +++ b/spec/ajv.ts @@ -4,3 +4,4 @@ const AjvClass: typeof Ajv = typeof window == "object" ? (window as any).ajv7 : export default AjvClass module.exports = AjvClass module.exports.Ajv = AjvClass +module.exports.default = AjvClass diff --git a/spec/ajv2019.ts b/spec/ajv2019.ts index 1025fb9d3c..5498edd032 100644 --- a/spec/ajv2019.ts +++ b/spec/ajv2019.ts @@ -5,3 +5,4 @@ const AjvClass: typeof Ajv2019 = export default AjvClass module.exports = AjvClass module.exports.Ajv = AjvClass +module.exports.default = AjvClass diff --git a/spec/ajv2020.ts b/spec/ajv2020.ts index 1e7f93c14b..9d6da3075c 100644 --- a/spec/ajv2020.ts +++ b/spec/ajv2020.ts @@ -5,3 +5,4 @@ const AjvClass: typeof Ajv2020 = export default AjvClass module.exports = AjvClass module.exports.Ajv = AjvClass +module.exports.default = AjvClass diff --git a/spec/ajv_jtd.ts b/spec/ajv_jtd.ts index 9245054a36..6b5a95c43f 100644 --- a/spec/ajv_jtd.ts +++ b/spec/ajv_jtd.ts @@ -5,3 +5,4 @@ const AjvClass: typeof AjvJTD = export default AjvClass module.exports = AjvClass module.exports.Ajv = AjvClass +module.exports.default = AjvClass diff --git a/spec/standalone.spec.ts b/spec/standalone.spec.ts index b123515c8e..57fc6aa8cb 100644 --- a/spec/standalone.spec.ts +++ b/spec/standalone.spec.ts @@ -292,6 +292,7 @@ describe("standalone code generation", () => { const m = requireFromString(moduleCode) testExport(m) testExport(m.Ajv) + testExport(m.default) function testExport(validate: AnyValidateFunction) { assert.strictEqual(validate(1), true)