-
-
Notifications
You must be signed in to change notification settings - Fork 883
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ECMAScript module #1310
Comments
Does v7 solve it? |
I just tried with 7.0.0-beta.3 and the warning is still there
Probably the new version changed the interface, now I got errors:
I changed:
into:
(strictDefaults, strictKeywords, strictNumbers were no longer recognized) With this fix the error at compile time disappeared, but then I have troubles at runtime. Please note that I'm trying a fast upgrade from v6 to v7 without studying any migration guide or changelogs, just to verify the commonjs dependencies warning. Probably I'm doing something wrong, but I think that it is no so important to make it work now (I'm waiting the final v7 release before starting the upgrade). Can I test something more? Do you have any suggestion to change the import or code to prevent the warning? |
Ajv is ES6 class in v7, it is not possible to make it callable without
strict mode is now enabled by default, it includes the functionality of all these option and some other restrictions - see docs/strict-mode.md
What exactly? It would help to know what fails. v7 is functionally backwards compatible, excluding draft-04 schemas support, but it has different defaults and formats were split to ajv-formats package. "Fast upgrade" can probably work for trivial cases, but in most cases it would help reviewing the release notes...
What is the code that generates the warning? Ajv is exported in this way, to be backwards compatible: export default class Ajv { /* ... */ }
module.exports = Ajv
module.exports.default = Ajv Which lines above cause the warnings? If you remove 2nd and 3rd do you still have it? Another issue I recently discovered and not yet sure how best to change that these exports overwrite all other exports that are not types. For example, even though I have these exports in Ajv: export {_, str, stringify, nil, Name, Code, CodeGen, CodeGenOptions} from "./compile/codegen" I can import types Name etc., but not other things from this export. I didn't look yet how best to address it. |
Thank you for the help @epoberezkin, I would like to be more helpful in my reporting but...
The problem is that I don't really understand the runtime error.
And the offending line seems to be this:
if I stop my validation function just before this line no exception is raised. It works fine with 6.12.6 (I only changed the version in package.json, changed the import and change the object creation by adding the
I'm not very helpful again... I tried to remove both the lines from dist/ajv.js (is the correct file?) but the warning is still there However, I don't want to waste your time with badly reported issues and confused errors. If my reports are helpful to you to understand the issue, we can continue, otherwise I may back to you with better reporting once migrated my app to ajv 7 (but I would like to do this after the official release) Thank you again for your help! |
The error is unrelated to ajv, it is because
Sure - I will keep the issue open for now |
Once back to v6 I put a couple of console.log around the ajv.getSchema
->
"#/definitions/User" is added with a json file:
Options in v6:
options in v7:
|
Btw, the exports are now targeting ESM modules and typescript - see Getting started. Yet to look at the issue. |
Going to close it. Please review the release notes - there are some changes in v7 that in many cases would make quick upgrade not possible. Please resubmit a specific failing case if it is still there. |
Hello @epoberezkin I fixed (or better, bypassed) the runtime error reported above by enabling the standalone generation of validation function. This works well with v7.0.1 except for the execution of tests with karma that fail due to duplicated validation functions as reported in #1361. |
What version of Ajv you are you using?
6.12.5
What problem do you want to solve?
Hello, I'm opening this issue because I did not find other discussions about that, please redirect me on the proper issue if you are already discussing it. I was looking for any solution for the Angular 10 warnings (CommonJS or AMD dependencies can cause optimization bailouts.), rather that simply ignore them by configuring allowedCommonJsDependencies in angular.json.
What do you think is the correct solution to problem?
I realized that a ECMAScript module would be needed to make Angular happy. Is there any plan to build ajv in that way?
Will you be able to implement it?
Unfortunately not
The text was updated successfully, but these errors were encountered: