-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Dynamic import for zxcvbn library #30104
Conversation
@NeOMakinG 🦸♂️ 🚀 🔎 |
Remember that we want to load core js optionally - #29995 😎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely need this inside the 8.0 release or it will be a big blocker for the adoption
@Oksydan you're a monster btw
@@ -22,6 +22,8 @@ | |||
* @copyright Since 2007 PrestaShop SA and Contributors | |||
* @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) | |||
*/ | |||
__webpack_public_path__ = window.prestashop.core_js_public_path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I get the purpose of this one? It allows using const zxcvbn = (await import('zxcvbn')).default;
and import from chunks right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jolelievre,
Webpack need publicPath
to be set so it can find files that have to be fetched example publicPath = "/themes/"
- domain.com/themes/chunkfilename
.
We can set publicPath
in webpack configuration to just /themes/
and that should work in 99% but if store physical_uri
is different than /
for example /store/
(domain.com/store/
) publicPath
will be /store/themes/
. That's why we need that variable to be set on the fly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @nicosomb,
I checked those cases
Case1
Physical_uri === /Presta+Shop/
=> OK
- Install > Information step
- FO > Create an account
- FO > Edit information
- FO > Create an account for a guest
- FO > Checkout > Create an account
Case2
Physical_uri === /PrestaShop/
=> OK
- Install > Information step => OK
- FO > Create an account => OK
- FO > Edit information => OK
- FO > Create an account for a guest => OK
- FO > Checkout > Create an account => OK
Case3
Physical_uri === /
=> OK
- Install > Information step => OK
- FO > Create an account => OK
- FO > Edit information => OK
- FO > Create an account for a guest => OK
- FO > Checkout > Create an account => OK
I attached screen records
Check.1.-.base.uri._.mp4
Case4
Physical_uri === /test/80x/
=> NOK
Install > Information step: OK
BO > Create a customer => OK
BO > Edit an employee password => OK
FO > Create an account => NOK
FO > Edit information => NOK
FO > Checkout > Create an account => NOK
The info messages are not displayed when typing the password
I attached a screen record
base.uri._test_80x_.NOK.mp4
I tried with 8.0.0RC1 => OK
8.0.0RC1.with.PR.ok.mp4
Thanks!
Hi @khouloudbelguith, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Oksydan,
Thanks for your feedback.
After some rechecks, it is ok ✔️
I checked with this
Also, automatic tests => OK ✔️
I checked when multistore enabled / I checked friendly URL enabled & disabled => OK ✔️
final_check.mp4
Also, I checked the size of core.js => ok
Thanks!
QA approved, well done! Message to the maintainers: do not forget to milestone it before the merge. |
Thank you @Oksydan @khouloudbelguith |
@khouloudbelguith good job. Thank you. |
zxcvbn
library is rly huge and shouldn't be loaded in core.js. We are providing new filed toprestashop
global variablecore_js_public_path
. It is being used for webpackpublicPath
on the fly to avoid problem when ruing prestashop inside catalog (domain.com/directory/
). For nowprestashop.checkPasswordScore
is asynchronous and it's returning a promise.zxcvbn
library is being loaded dynamically on callingprestashop.checkPasswordScore
function. I will providePR
to classic and hummingbird.-chunk.js
.2. If testing with classic-theme PrestaShop/classic-theme#67 apply changes from this PR.
3. Go to FO register page.
4. Type inside password field, (you can open network tab in browser, there should be js file loaded on password check).
5. Password policy should be working as before.
physicial_uri
Before:
core.js size:
940kB
After:
core.js size:
144kB