Automattic / Automattic/jetpack

DNA: automate version management of files enqueued from within a package

Open
#16,972 0 comments 0 reactions 0 assignees View on GitHub
[Focus] Jetpack DNA [Pri] Normal Enhancement
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.