magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.45k stars 9.29k forks source link

jquery.validate.js does not get minified correctly #36013

Open git-seb opened 2 years ago

git-seb commented 2 years ago

Preconditions and environment

How it should be: jquery validate min js right

Don't have deep knowledge of Magento but this is all the info I can provide.

Steps to reproduce

  1. Turn on Minify JS files
  2. Do a Google PageSpeed test
  3. Shows result saying jquery.validate.min.js minification could be improved
  4. When checking the actual file jquery.validate.min.js it is indeed incorrectly minified

Expected result

Minify jquery.validate.min.js correctly

Actual result

Minification of jquery.validate.min.js is incorrect jquery validate min js wrong

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @git-seb. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

engcom-Hotel commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, here is your Magento Instance: https://3799947449e4bad23f91dcee07ec26fe.instances.magento-community.engineering Admin access: https://3799947449e4bad23f91dcee07ec26fe.instances.magento-community.engineering/admin_7b3e Login: 7aac3ab7 Password: e741a5337917

engcom-Hotel commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, here is your Magento Instance: https://3799947449e4bad23f91dcee07ec26fe.instances.magento-community.engineering Admin access: https://3799947449e4bad23f91dcee07ec26fe.instances.magento-community.engineering/admin_0eff Login: fe47182a Password: d6b2666ed978

engcom-Hotel commented 2 years ago

@magento give me 2.4.5 instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, here is your Magento Instance: https://22dcddfc581ace05c5c80fae5246308c.instances.magento-community.engineering Admin access: https://22dcddfc581ace05c5c80fae5246308c.instances.magento-community.engineering/admin_679b Login: 68411098 Password: ea9b240a04e1

engcom-Lima commented 2 years ago

Hi @git-seb

We have tried to reproduce this issue Precondition: • Magento 2.4-develop && 2.4.5 • PHP 8.1

We have followed below steps 1.We have enabled Minify JavaScript Files as shown below

image

2.After we run the frontend url in Google PageSpeed image

  1. We have checked the jquery.validate.min.js is passed (checked in both mentioned M2 versions)

image

Please let us know if we are missing any steps here.

Thanks

git-seb commented 2 years ago

Hi @engcom-Lima,

as you can see on your last screenshot, Google says jquery.validate.min.js can be optimized even though it is stated as passed. If you check that file you can see it is not minified correctly (see link https://22dcddfc581ace05c5c80fae5246308c.instances.magento-community.engineering/static/version1661761332/frontend/Magento/luma/en_US/jquery/jquery.validate.min.js from your instance).

Thanks.

engcom-Hotel commented 2 years ago

@magento give me 2.4-develop instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, here is your Magento Instance: https://3799947449e4bad23f91dcee07ec26fe.instances.magento-community.engineering Admin access: https://3799947449e4bad23f91dcee07ec26fe.instances.magento-community.engineering/admin_eaf4 Login: 58a40937 Password: 938d907076e8

engcom-Hotel commented 2 years ago

@magento give me 2.4.5 instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, here is your Magento Instance: https://22dcddfc581ace05c5c80fae5246308c.instances.magento-community.engineering Admin access: https://22dcddfc581ace05c5c80fae5246308c.instances.magento-community.engineering/admin_f3f8 Login: 355e5f29 Password: eec8a16061e0

engcom-Hotel commented 2 years ago

@magento give me 2.4.4 instance

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for your request. I'm working on Magento instance for you.

magento-deployment-service[bot] commented 2 years ago

Hi @engcom-Hotel, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

engcom-Lima commented 2 years ago

:heavy_check_mark: Issue confirmed

Issue got reproduced in 2.4-develop && 2.4.5 branch.

Description: After enabling the Minify JavaScript Files in magento, the jquery.validate.js file is partially minified.

Prerequisite:

Steps to Reproduce:

  1. Enable Minify JavaScript Files in magento.
  2. Run the frontend url in Google PageSpeed
  3. Check the jquery.validate.js.

Expected result: jquery.validate.min.js file should be minified correctly Actual result: jquery.validate.min.js file incorrectly minified Screenshots:

Checked both M2 versions

image

Hence,confirming the issue.

Thanks

github-jira-sync-bot commented 2 years ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-6594 is successfully created for this GitHub issue.

m2-assistant[bot] commented 2 years ago

:white_check_mark: Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

rostilos commented 1 year ago

@magento I am working on this

JelleGe commented 1 year ago

Any update on this issue?

rostilos commented 1 year ago

I found the root of the error, but it is not in the m2 files, but in third-party files/libs ( jquery libs or in the minifactor itself). Maybe I could deliver some plugin later ( There is a certain regular expression in the jquery.validate file that stops execution when approached by the minifier

rostilos commented 1 year ago

https://github.com/tedious/JShrink/issues/110 For now, I'm following the updates here. I think it makes sense to wait until the original module has this problem solved and update it to the latest version.

minhluan259 commented 7 months ago

Simply solve it by updating JShink:

cd project_root 
cd vendor/magento/framework/
composer require tedivm/jshrink ^1.7 --no-update
cd project_root 
composer update
rostilos commented 7 months ago

@minhluan259 Thank you. I will create a separate MR a little later ( if updating the module really solves the problem )

git-seb commented 7 months ago

@minhluan259 Thanks for your input. That means fixing this issue is by updating the JShrink plugin from 1.4 to 1.7. I do think Magento devs have not done that yet because in version 1.5 of JShrink PHP 7.0 support dropped. Starting from Magento 2.4.6 (june 2023), the devs dropped support for PHP 7.4 but left JShrink unchanged. That is just assuming tho.

Side note for others, when doing this command, the following also installed/updated (at least on my 2.4.6-p3 environment):

git-seb commented 7 months ago

The following error was showing up when compliming: Application code generator... 3/9 [=========>------------------] 33% 11 secs 386.0 MiBPHP Fatal error: Cannot declare trait Composer\Repository\CanonicalPackagesTrait, because the name is already in use in /vendor/magento/framework/vendor/composer/composer/src/Composer/Repository/CanonicalPackagesTrait.php on line 23

I've reverted version 1.7 back to 1.4 and did composer reinstall magento/framework in root folder. I think this happened because of some dependencies. Not sure.. Maybe someone else can include it in a different way and test it?

minhluan259 commented 7 months ago

@git-seb If you are using Magento 2.4.6-p3, just run composer update in the project folder. It will automatically update JShrink to v1.7

git-seb commented 5 months ago

Just wanted to give a heads up on this thread. This is not yet fixed. Even after updating to Jshrink v1.7. I can confirm on multiple production environments.

sgautamrave commented 4 months ago

Hi, Did we get any solution for this issue?

tete2soja commented 1 month ago

Hello,

We are facing the same issue. Any progress about a merge about it?