jQuery-Form-Validator
jQuery-Form-Validator copied to clipboard
Critical dependency: the request of a dependency is an expression.
Hi,
Im using webpack and when i compile my javascript code with jQuery-Form-Validator im getting this Warning:
WARNING in ./~/jquery-form-validator/form-validator/jquery.form-validator.min.js 9:12821-12866 Critical dependency: the request of a dependency is an expression
Validator still works but im anxious about it.
I have the same issue, the warning is caused by this require:
require([e+(".dev.js"===e.slice(-7)?h:"")],g)
or in unminified source code:
require([scriptUrl + ( scriptUrl.slice(-7) === '.dev.js' ? cacheSuffix : '' )], moduleLoadedCallback);
Hi is this fixed ?
I'm having the same issue
I have exactly the same issue.
The whole loadModules
function is causing this issue.
related source can be found here:
https://github.com/victorjonsson/jQuery-Form-Validator/blob/6bc133ba8d57bc6ce37bab95fd1c6360e4d984e7/form-validator/jquery.form-validator.js#L1016-L1130
And the modules feature description can be found here:
- https://github.com/victorjonsson/jQuery-Form-Validator#jquery-form-validator
This is achieved by grouping together validation functions in "modules", making it possible to load only those functions that's needed to validate a particular form.
- https://github.com/victorjonsson/jQuery-Form-Validator#default-validators-and-features-no-module-needed
- Then a list of various validation modules follows, like: https://github.com/victorjonsson/jQuery-Form-Validator#module-security
- https://github.com/victorjonsson/jQuery-Form-Validator#creating-a-custom-module
IMHO this is a bug, async loading of additional logic should be done by a bundler or loader (Webpack, Rollup, SystemJS, you name it)
I am getting the warning as well. Any example of using this with webpack?
@AndyOGo Well, this jquery-plugin was created (relatively) long before build tools like webpack became an industry standard. I would label it as an obsolete feature, rather than a bug. Nothing is broken in this case. I understand that you don't want to have warnings in your builds but everything still works as expected.
If I would have the possibility to rewrite the core of this plugin many things would be done differently, no coupling with jquery, amd-modules from the start, validation invoked as a chain-of-responsibility, latest ecmascript features etc... But at the moment I don't have the possibility to invest the amount of time required to complete such a task. I simply can't remove $.formUtils.loadModules
since such an undertaking would required a large refactor of the entire code base, it would also radically change the way this plugin is used when not having any build tools at all.
I would gladly discuss further how to take this "framework" in to the future. If one would let all the validation modules stay as they are at the moment, one could freely redesign the core of the framework, without having to bother with backwards compatibility.
@victorjonsson Thanks for your answer. You are right, standards for module management increased massively.
Refactoring it will be a lot of work.
@victorjonsson could you at least add an // webpack:ignore
comment right after you use require()
edit: oops sorry there is no ignore of this.
first install
npm i script-loader
require('script-loader!jquery-form-validator/form-validator/jquery.form-validator.min');
I have the same problem using Laravel-mix I had tried @nazaninhesari way but still no luck !
Guys I have solved this problem. check this link .