Magento2: JS files located outside the web/js directory

Created on 21 Jun 2018  路  11Comments  路  Source: magento/magento2

Summary

Some JS files are direct children of web rather than web/js. This does not follow instructions from the dev docs thus is confusing.

Place the custom component source file in one of the following locations:
Your theme JS files: /web/js or /_/web/js
Your module view JS files: /view/frontend/web/js

There are more instances of this:

  • vendor/magento/module-payment/view/frontend/web/transparent.js
  • vendor/magento/module-payment/view/frontend/web/cc-type.js
  • vendor/magento/module-search/view/frontend/web/form-mini.js
  • vendor/magento/module-sales/view/frontend/web/gift-message.js

There are more but I'm pushed for time at the minute.

Preconditions

  1. Magento 2.2 - This is irrelevant as it appears in all versions

Steps to reproduce

  1. Go to https://github.com/magento/magento2/tree/2.2-develop/app/code/Magento/Captcha/view/frontend/web and look where captcha.js and onepage.js is located.

Expected result

  1. JS files to be inside web/js as per the dev docs.

Actual result

  1. JS files are direct children of web, this is inconsistent with the dev docs.

This is confusing as the dev docs instructs developers to use certain locations yet the core does not follow this, either the files should be relocated to be inside web/js or the dev docs should be updated. Unless there is a valid reason why the files are outside web/js?

FrameworCode Fixed in 2.2.x Fixed in 2.3.x Clear Description Confirmed Format is valid Ready for Work Reproduced on 2.1.x Reproduced on 2.2.x Reproduced on 2.3.x

All 11 comments

Hi @BenSpace48. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [x] Summary of the issue
  • [x] Information on your environment
  • [x] Steps to reproduce
  • [x] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me {$VERSION} instance

where {$VERSION} is version tags (starting with 2.2.0+) or develop branches (2.2-develop +).
For more details, please, review the Magento Contributor Assistant documentation

@BenSpace48, thank you for your report.
We've acknowledged the issue and added to our backlog.

Hi @BenSpace48

Do you need below files in web/js folder and captcha.js and onepage.js ?

  • vendor/magento/module-payment/view/frontend/web/transparent.js
  • vendor/magento/module-payment/view/frontend/web/cc-type.js
  • vendor/magento/module-search/view/frontend/web/form-mini.js
  • vendor/magento/module-sales/view/frontend/web/gift-message.js

Hi @hitesh-wagento

Yeah for consistency with the dev docs and other files, and general best practices.

I think there are more files than the ones I've listed, they were just the first few I discovered whilst looking into it.

Ok Thanks @BenSpace48

I am working on this PR

Hi @BenSpace48. Thank you for your report.
The issue has been fixed in magento/magento2#16582 by @hitesh-wagento in 2.2-develop branch
Related commit(s):

The fix will be available with the upcoming 2.2.7 release.

@magento-engcom-team give me 2.2.5 instance

Hi @BenSpace48. Thank you for your request. I'm working on Magento 2.2.5 instance for you

Hi @BenSpace48, here is your Magento instance.
Admin access: https://i-16302-2-2-5.engcom.dev.magento.com/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

Hi @BenSpace48. Thank you for your report.
The issue has been fixed in magento/magento2#16708 by @hitesh-wagento in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.0 release.

Hi @BenSpace48. Thank you for your report.
The issue has been fixed in magento/magento2#19583 by @rbayet in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

Was this page helpful?
0 / 5 - 0 ratings