Skip to content

Commit

Permalink
chore: backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jarqvi committed Jul 13, 2024
1 parent 2f6ea7c commit fdf7e70
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/standalone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends SchemaEnv | string>(
Expand Down
1 change: 1 addition & 0 deletions spec/ajv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions spec/ajv2019.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ const AjvClass: typeof Ajv2019 =
export default AjvClass
module.exports = AjvClass
module.exports.Ajv = AjvClass
module.exports.default = AjvClass
1 change: 1 addition & 0 deletions spec/ajv2020.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ const AjvClass: typeof Ajv2020 =
export default AjvClass
module.exports = AjvClass
module.exports.Ajv = AjvClass
module.exports.default = AjvClass
1 change: 1 addition & 0 deletions spec/ajv_jtd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ const AjvClass: typeof AjvJTD =
export default AjvClass
module.exports = AjvClass
module.exports.Ajv = AjvClass
module.exports.default = AjvClass
1 change: 1 addition & 0 deletions spec/standalone.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ describe("standalone code generation", () => {
const m = requireFromString(moduleCode)
testExport(m)
testExport(m.Ajv)
testExport(m.default)

function testExport(validate: AnyValidateFunction<unknown>) {
assert.strictEqual(validate(1), true)
Expand Down

0 comments on commit fdf7e70

Please sign in to comment.