Skip to content

Commit

Permalink
Boost: Use "critical css gen" package from the monorepo (#39509)
Browse files Browse the repository at this point in the history
* Update Boost to use "critical css gen" package from the monorepo

* add changelog

* Update Boost to use new browser and node from "critical css gen" package

* add changelog

* Update package entry points

* Cleanup package entry points

* Use dynamic import for global type definitions

* Add browser entry point back to package

* Use dynamic import for css generator

* Don't use destructuring

* Update default entry point to use browser version

* Update Boost to use updated package entry point

* Simplify package build

* Remove unnecessary dependency enqueue

* Attempt to fix tests

* Rename dynamically imported file

* Merge dynamic import files

* Add build step for tests

* Cleanup build for tests

* Fix tests breaking due to missing package build

* Update package entry points

Co-authored-by: Brad Jorsch <[email protected]>

* Add helper for critical css generator import

* update changelogs

---------

Co-authored-by: Brad Jorsch <[email protected]>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/11214134299

Upstream-Ref: Automattic/jetpack@ce32881
  • Loading branch information
dilirity authored and matticbot committed Oct 7, 2024
1 parent 0d346cd commit 75b6e29
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 146 deletions.
18 changes: 0 additions & 18 deletions app/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
use Automattic\Jetpack_Boost\Lib\Analytics;
use Automattic\Jetpack_Boost\Lib\Environment_Change_Detector;
use Automattic\Jetpack_Boost\Lib\Premium_Features;
use Automattic\Jetpack_Boost\Modules\Modules_Index;
use Automattic\Jetpack_Boost\Modules\Modules_Setup;
use Automattic\Jetpack_Boost\Modules\Optimizations\Critical_CSS\Critical_CSS;

class Admin {
/**
Expand Down Expand Up @@ -83,29 +81,13 @@ public function enqueue_scripts() {
*/
$internal_path = apply_filters( 'jetpack_boost_asset_internal_path', 'app/assets/dist/' );

$critical_css_gen_handle = 'jetpack-boost-critical-css-gen';

Assets::register_script(
$critical_css_gen_handle,
$internal_path . 'critical-css-gen.js',
JETPACK_BOOST_PATH,
array(
'in_footer' => true,
)
);

$admin_js_handle = 'jetpack-boost-admin';

$admin_js_dependencies = array(
'wp-i18n',
'wp-components',
);

// Enqueue the critical CSS generator script if Critical CSS is available.
if ( ( new Modules_Index() )->is_module_available( Critical_CSS::get_slug() ) ) {
$admin_js_dependencies[] = $critical_css_gen_handle;
}

Assets::register_script(
$admin_js_handle,
$internal_path . 'jetpack-boost.js',
Expand Down
2 changes: 0 additions & 2 deletions app/assets/dist/critical-css-gen.js

This file was deleted.

10 changes: 0 additions & 10 deletions app/assets/dist/critical-css-gen.js.LICENSE.txt

This file was deleted.

2 changes: 1 addition & 1 deletion app/assets/dist/jetpack-boost.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-date', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => '85533f2e10cbf2a9c573');
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-date', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives'), 'version' => 'a33af66e60d0010c6e45');
52 changes: 26 additions & 26 deletions app/assets/dist/jetpack-boost.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/dist/jetpack-critical-css-gen.js

Large diffs are not rendered by default.

60 changes: 30 additions & 30 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-a8c-mc-stats",
"reference": "91e299066edc191b13497c0ec4fc4cfebec012f5"
"reference": "c8b1fd6418601ced0dd4645d1a141211a99b8412"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -60,7 +60,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-admin-ui",
"reference": "3887a2ff87d900825c2ba17b58e49505ba8f360e"
"reference": "ecb71a1c90f84e51b243b70b4924f507bc69b629"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -125,7 +125,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-assets",
"reference": "bef6c160a906876392cd1f2a2b028f8e06f16cba"
"reference": "b8fac6ba52b19e65ac1ccdd74d9088f81884bdd1"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -194,7 +194,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-autoloader",
"reference": "2e7506312e2d5716181fe4d3264baa110e00dc2a"
"reference": "42a3c98d645305708b51210d7ca5872d917f0e98"
},
"require": {
"composer-plugin-api": "^1.1 || ^2.0",
Expand Down Expand Up @@ -261,7 +261,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-boost-core",
"reference": "354140c6fdfd1396e0e6d5578e470f7eda2293b9"
"reference": "21ea06ca85612f7b288a99e86fd31efa9b088854"
},
"require": {
"automattic/jetpack-connection": "^5.1.2-alpha",
Expand Down Expand Up @@ -329,7 +329,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-boost-speed-score",
"reference": "a519cf2d1f22cfc60b8afaa8a8e4d3dd4967632f"
"reference": "868e9dd5b8d26c39bbb8b886df9fd069b0f08079"
},
"require": {
"automattic/jetpack-boost-core": "^0.2.12",
Expand Down Expand Up @@ -405,7 +405,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-composer-plugin",
"reference": "ec86f88c305725ab32714392fdb3987337b5a7bc"
"reference": "dc5fe0b94485e92eebee69f00e65b3961d59a73f"
},
"require": {
"composer-plugin-api": "^2.1.0",
Expand Down Expand Up @@ -465,7 +465,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-config",
"reference": "a2b495a2cdfea1e2f572bf017d8a640cdb1d7211"
"reference": "2e237419a1b4874dba1a46ec60a86c82bc69f945"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -540,7 +540,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-connection",
"reference": "2692c5175d609eedeca2f16b638f97f1bd0638fa"
"reference": "0447cc37c0eb088ebd977328ca5108f1d0f5f479"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.3",
Expand Down Expand Up @@ -630,7 +630,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-constants",
"reference": "8e3ac96433d3e7f182d5b4ea2deab57f36400d48"
"reference": "62fbe9da4292961a41cf09ffe4945dcf976f3372"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -684,7 +684,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
"reference": "c4808435f07fb59f60dca607b097d1c018ec4463"
"reference": "3bc4b0a1a6769630b5f5dda9aee34e76654d4ef3"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -737,7 +737,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-explat",
"reference": "d992656d63aade669e2b3122c87b3f104a3c54d3"
"reference": "a8b596d77e1947bfda1f2c91e15d7a4ceb13573f"
},
"require": {
"automattic/jetpack-connection": "^5.1.2-alpha",
Expand Down Expand Up @@ -812,7 +812,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-image-cdn",
"reference": "4d4a7a1ec83877fdd8c8e2de1ba27c1823188ae7"
"reference": "995e71a0b3783aaf700bb19c66da161b70e2ac8a"
},
"require": {
"automattic/jetpack-assets": "^2.3.9-alpha",
Expand Down Expand Up @@ -878,7 +878,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-ip",
"reference": "327fc1091ec55f9d74d51192290693f7de2ed1a5"
"reference": "682dbcdc983d827f6fd543d24b0fd2436dfa53eb"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -936,7 +936,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-jitm",
"reference": "2e0db3eae42e8756a62e6e8b66c10cc8bdfdde89"
"reference": "2d31b42f2060b91f656cd3d82fe04d1b57f04c1f"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.3",
Expand Down Expand Up @@ -1011,7 +1011,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-licensing",
"reference": "ebfbe57e5bf3702185eda5e09d48ecc5a1069a06"
"reference": "24c695150f80ed920ae741c51d31b0389ebef35c"
},
"require": {
"automattic/jetpack-connection": "^5.1.2-alpha",
Expand Down Expand Up @@ -1073,7 +1073,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-logo",
"reference": "0f319362a33f117b11282307f19c4fb0b044ed55"
"reference": "d6b15e8182719c494f4c6fcac520907f2ab124ba"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1126,7 +1126,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-my-jetpack",
"reference": "94ff76f971004707623d3a05741a2a46b0c50b38"
"reference": "02c97e87d32cfc7b8594e8cfb014b045af721cc0"
},
"require": {
"automattic/jetpack-admin-ui": "^0.4.5",
Expand Down Expand Up @@ -1228,7 +1228,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-password-checker",
"reference": "8985ce24e06e124bb8c08c185c3c73e4f805c49a"
"reference": "c5730a7048b04123832cc3ce5941af4ee90f26de"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1289,7 +1289,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plans",
"reference": "a9e451a933009842d3f46722048e2e21039deacd"
"reference": "a5504720c5c0f09b30f921ee5d200ba1fd5634d1"
},
"require": {
"automattic/jetpack-connection": "^5.1.2-alpha",
Expand Down Expand Up @@ -1357,7 +1357,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plugin-deactivation",
"reference": "61c2030f6a099b7ddb2eac2ca2cf7dd80d2573a9"
"reference": "27fe45c64ee24b505133048415e8bbd83d4965ae"
},
"require": {
"automattic/jetpack-assets": "^2.3.9-alpha",
Expand Down Expand Up @@ -1425,7 +1425,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-plugins-installer",
"reference": "4757034d4948ebddb29e27235de6c67990ea776e"
"reference": "fa9a002776bf0f5c28bead34ac20d5139d8a0461"
},
"require": {
"automattic/jetpack-a8c-mc-stats": "^2.0.3",
Expand Down Expand Up @@ -1481,7 +1481,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-protect-models",
"reference": "ee1661909d26eddaa235beebae252384d4a49c18"
"reference": "77f6f0246a4ed03e4ea1148764cc0e7944818058"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1551,7 +1551,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-protect-status",
"reference": "9fc5f90c2d5c8d8b0adce2538bad08667343adc8"
"reference": "5408664a5bb9700ddca0ff79901eadb8924ca079"
},
"require": {
"automattic/jetpack-connection": "^5.1.2-alpha",
Expand Down Expand Up @@ -1626,7 +1626,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-redirect",
"reference": "a801a1fb8a547abe810456db146cf341f9a590de"
"reference": "0a0698522eeb162cab7694280050805f6aeb8bd9"
},
"require": {
"automattic/jetpack-status": "^4.0.2",
Expand Down Expand Up @@ -1681,7 +1681,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-roles",
"reference": "55ab75b443647dd04b977c440629e8fea97b2479"
"reference": "a5f855ab5666d639b82d2ad83f9263e292bf8427"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1735,7 +1735,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-schema",
"reference": "6a83fd738f18d4985c0273fc49c6d89e114fe510"
"reference": "9cb3cbbc49bdc8637818178e96b46789b9175bae"
},
"require": {
"php": ">=7.0"
Expand Down Expand Up @@ -1805,7 +1805,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-status",
"reference": "793a382dce5855517fbc41f8ccbbdb4d65a2fdad"
"reference": "26c4fe53b40f20da4248b5be21ddef04aa1c783f"
},
"require": {
"automattic/jetpack-constants": "^2.0.4",
Expand Down Expand Up @@ -1869,7 +1869,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-sync",
"reference": "4c6af6c3b52a4d4af4a98f663aed7f22737db49b"
"reference": "310b5ad88421ed390b2d746475b2be13be0f2ad6"
},
"require": {
"automattic/jetpack-connection": "^5.1.2-alpha",
Expand Down Expand Up @@ -1947,7 +1947,7 @@
"dist": {
"type": "path",
"url": "/tmp/jetpack-build/Automattic/jetpack-wp-js-data-sync",
"reference": "d319f34cd032318bb44b23a917f246b6f72ace19"
"reference": "e2730c3f3ef19ea78c25d6b415d0fac2695ffc2c"
},
"require": {
"automattic/jetpack-schema": "^0.1.1",
Expand Down
Loading

0 comments on commit 75b6e29

Please sign in to comment.