Automattic / Automattic/jetpack
DNA: automate version management of files enqueued from within a package
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
When using `wp_enqueue_`* from within Jetpack, we can rely on `JETPACK__VERSION` to version the files being enqueued.
In packages, however, we do not have access to this constant. We end up defining a constant in each package individually, but we do not currently have a way to ensure that constant is updated to match package version updates:
- https://github.com/Automattic/jetpack/blob/4392a22d643eaf812f42c37739bf675ea3ef7f34/packages/jitm/src/class-jitm.php#L24
- https://github.com/Automattic/jetpack/blob/e3b90f4807dfdc334ac81e9455a9bab5023e0ffc/packages/lazy-images/src/lazy-images.php#L42
It would be nice to find a way to automate this to avoid cache busting issues in the future when making changes to those resources.
An alternative could be to have a default in each package of something like `gmdate( 'YW' )`, and have a filter allowing you to overwrite that value; we could then overwrite that value with `JETPACK__VERSION` in the Jetpack plugin.
Contributor guide
Research direction
Start by comparing the package version constants in packages/jitm/src/class-jitm.php and packages/lazy-images/src/lazy-images.php with the package versioning flow. Review how wp_enqueue_* calls receive their versions and how JETPACK__VERSION is used, then define a way to keep package-enqueued resources synchronized and verify that package updates prevent stale cached files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- release
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100