Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: using ajv v7 in ES5 environments #1364

Closed
aladdin-add opened this issue Dec 21, 2020 · 5 comments 路 Fixed by #1365
Closed

Docs: using ajv v7 in ES5 environments #1364

aladdin-add opened this issue Dec 21, 2020 · 5 comments 路 Fixed by #1365

Comments

@aladdin-add
Copy link
Contributor

aladdin-add commented Dec 21, 2020

We are using the package in a web app (supporting es5 env), and got erros after upgrading to ajv v7.0.1.

Do you still want to support pre-es6 env? Or just update the docs to clarify its requirement. 馃槃

@epoberezkin
Copy link
Member

There is an option to generate es5 code (new Ajv({code:{es5:true}})), it's not a bug - the default is to generate ES6 code. Please see the release notes - there are some other breaking changes.

@epoberezkin
Copy link
Member

And if you need to use Ajv itself in pre-ES6 env you need to recompile TypeScript to an earlier target - it's set to 2018 in the bundled compiled code.

@epoberezkin
Copy link
Member

Probably it deserves the section in the docs :)

@epoberezkin epoberezkin reopened this Dec 21, 2020
@epoberezkin epoberezkin changed the title ajv v7 does not support pre-es6 environment Docs: using ajv v7 in ES5 environments Dec 21, 2020
@aladdin-add
Copy link
Contributor Author

aladdin-add commented Dec 22, 2020

I've got a new error when trying to compile the ts(using @babel/preset-typescript) code:

image

is there a way to avoid using the import = syntax?

@epoberezkin
Copy link
Member

The only way to avoid import = syntax is to use esModuleInterop option - in results in bigger code size and seems to be forcing dependencies to also use this option. You should be importing from dist folder (that鈥檚 where main points to), so it shouldn鈥檛 really matter.

Or you can alway recompile typescript to older/newer JS version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants