jQuery-Form-Validator icon indicating copy to clipboard operation
jQuery-Form-Validator copied to clipboard

Critical dependency: the request of a dependency is an expression.

Open smoleniuch opened this issue 7 years ago • 11 comments

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.

smoleniuch avatar May 22 '17 10:05 smoleniuch

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);

ezze avatar Jun 01 '17 18:06 ezze

Hi is this fixed ?

I'm having the same issue

Lidofernandez avatar Oct 01 '17 21:10 Lidofernandez

I have exactly the same issue.

andrey-andreev avatar Nov 29 '17 13:11 andrey-andreev

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)

AndyOGo avatar Dec 21 '17 13:12 AndyOGo

I am getting the warning as well. Any example of using this with webpack?

swsalim avatar Mar 01 '18 04:03 swsalim

@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 avatar Mar 01 '18 09:03 victorjonsson

@victorjonsson Thanks for your answer. You are right, standards for module management increased massively.

Refactoring it will be a lot of work.

AndyOGo avatar Mar 01 '18 10:03 AndyOGo

@victorjonsson could you at least add an // webpack:ignore comment right after you use require()

edit: oops sorry there is no ignore of this.

baskan avatar Mar 10 '18 14:03 baskan

first install npm i script-loader

require('script-loader!jquery-form-validator/form-validator/jquery.form-validator.min');

nazaninhesari avatar Dec 05 '18 08:12 nazaninhesari

I have the same problem using Laravel-mix I had tried @nazaninhesari way but still no luck !

ghonchesefidi avatar Feb 20 '19 06:02 ghonchesefidi

Guys I have solved this problem. check this link .

ghonchesefidi avatar Feb 20 '19 07:02 ghonchesefidi