-
Notifications
You must be signed in to change notification settings - Fork 849
Lazy Images: Move into a package #16657
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
Conversation
|
Thank you for the great PR description! When this PR is ready for review, please apply the E2E results is available here (for debugging purposes): https://jetpack-e2e-dashboard.herokuapp.com/pr-16657 Scheduled Jetpack release: September 1, 2020. |
jeherve
left a comment
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.
Tests appear to be failing at the moment. Do you think you could take a look?
I wonder if it may be possible to switch to relying on something like WorDBless instead of having to set up WP in here?
packages/lazy-images/.phpcs.xml.dist
Outdated
| @@ -0,0 +1,36 @@ | |||
| <?xml version="1.0"?> | |||
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.
Do we need this custom configuration here? Can we rely on the existing configuration instead?
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.
Looking more into this, I now understand better the processes on Jetpack :) I have now removed it so the existing configuration will be use instead.
| @@ -0,0 +1,12 @@ | |||
| const path = require("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.
I wonder if we should leave this out of the package, and handle file minification from the Jetpack plugin instead?
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.
Agreed, let's do that and keep the build scripts out of the package.
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.
I have created a new webpack config for packages at the root of the repo and added a new command to the package.json. Hopefully this is closer to what it should be. The webpack config for packages can be extended later if required i guess?
|
Thanks for the feedback @jeherve. I have addressed all of your feedback except for the failure of the unit tests. Today I tried to use WorDBless and all the tests would work with it except for These 2 tests are making use of |
…ic/jetpack into add/jetpack-lazy-images-package
|
@davidlonjon @leogermani I am still getting test failures after merging master: |
|
Actually there are even more different issues, if you click around the test failures. At least a few seem unrelated to these changes and should be fixed in master. |
…n output does not get the lazy treatment when lazy images feature is skipped
|
First, thank you so much @leogermani for the work you have done with Regarding the But your comment actually prompted me to look again at it and since we only want to test the @gravityrail, regarding the tests failure you've seen. It turns out the reason was that the Finally all the tests are now passing again and it seems the integration works well enough again. Hopefully this is now it and we should be in a state that it could be merged? cc @jeherve |
leogermani
left a comment
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.
LGTM
|
Seems ready to go. @jeherve just confirm your request change was addressed. |
gravityrail
left a comment
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.
LGTM, thanks for all your work on the tests
* master: (23 commits) Premium Blocks: set blocks availability (#16898) Compat Package: Fix method declaration compatibility (#16900) Jetpack Dashboard: More meaningful error notices. (#16883) Connection REST API: Unit test for the `remote_authorize` request. (#16879) use blog token to request jetpack.updateBlog (#16698) Improve Story block media loading (#16663) Simplify error notices for broken connections (#16655) Use new heartbeat package (#16285) wrap-paid-block: remove component. deprecated. (#16895) Social Previews: improve preview description handling (#16889) Stats module use blog token (#16727) Form Block: add a new Consent Field, a new Newsletter setting, and a new newsletter variation (#16808) AAG: Backup card, fall back to VP content in case of /rewind API error. (#16867) Donations: Fix dependencies (#16892) Creative Mail: update option to lowercase (#16861) Premium Blocks: Implement the new design (#16611) Requests to Stats CSV use the blog token (#16716) Update spacing around sharing buttons to avoid no bottom margin below the customize link. (#16811) Jetpack SSO: Cleaning up the `requestNonce` API request. (#16830) Donations: Update plans when currency changes (#16844) ...
ff30622
|
I pushed a commit merging master back into this branch to fix a merge conflict with the |
leogermani
left a comment
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.
Approving again after rebase
|
Internal reference: D48486-code |
Co-authored-by: Daniel Walmsley <[email protected]> Co-authored-by: leogermani <[email protected]>
Changes proposed in this Pull Request:
Does this pull request change what data or activity we track or use?
No it should not.
Testing instructions:
wp-admin/admin.php?page=jetpack_modulesdata-lazy-loaded="1"property.Proposed changelog entry for your changes:
Additional development context:
Here are some additional information related to the decision I have made for migrating the
Lazy Imagesmodule into a standalone package. I have made some assumptions which might be incorrect and therefore some changes will need to be amended based on your guidance.While migrating the module to a package, I tried to remove or update references to the module source file in order place of the repository such as from:
.eslintignoremodules/photon-cdn/jetpack-manifest.php: I am not sure if this one would be generated automatically so i just updated the path to the JavaScript files manually.phpunit.xml.distmodules/lazy-images.php: I kept this file even though the module source moved into a package as I wanted to make sure the module pattern activation/deactivation still work. I have also moved some of the credit comments into the package itself (packages/lazy-images/src/lazy-images.php) as it seems appropriate to belong there as the package can be a standalone download in any project.In
packages/lazy-images/src/lazy-images.php:8.8in the PHPDoc@sinceentry but I am unsure if this would be the correct version.is_amp_requestbecause as a standalone package it cannot rely anymore on theJetpack_AMP_Support::is_amp_request()method.get_file_url_for_environmentbecause as a standalone package it cannot rely anymore on theAssets::get_file_url_for_environmentmethod as the JS asset is located within the package.In
packages/lazy-images/tests/php/test_class.lazy-images.php:In
packages/lazy-images/src/js/lazy-images.js:I have introduced some tooling for building assets, running unit tests and linters. The reason is because I was not sure if/how to integrate these within the Jetpack workflow. So these changes might need to be altered.
lazy-images.jsfile was generated by the Jetpack build workflow. Here I have introduced a Webpack config to build the minified version. Theyarn buildcommand allows building the minified version of the JavaScript.packages/lazy-images/tests/php/test_class.lazy-images.php) extends theWP_UnitTestCaseclass, it seems that thewordpress-tests-libis required. Therefore I also needed to have a bootstrapped WordPress testing environment which I am creating with Docker. Theyarn test:phpunitcommand allows to run the PHP unit tests.yarn php:lintcommand allows to run the lint the PHP code base.As I mention some of my assumptions and decisions above might be incorrect and will need to be adapted to an existing Jetpack workflow.