From 289fe99a5dd26a2db6eadc76a49ea8797321eed8 Mon Sep 17 00:00:00 2001 From: Olivier Gorzalka Date: Wed, 30 Sep 2026 10:24:00 +0200 Subject: [PATCH] fix: enqueue the Vite client with no version The modules Vite serves import /@vite/client by its bare URL; enqueued with WordPress's version appended, the client loaded twice, as two modules with two HMR connections. Regression from v13.34.0-beta. --- CHANGELOG.md | 3 +++ src/Asset/Infrastructure/Services/AssetEnqueuer.php | 4 +++- tests/Feature/Asset/AssetEnqueuerTest.php | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 577f9c5f..5d7e6192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/Pollora/framework/compare/v13.34.0-beta...develop) +### Fixed +- While Vite ran hot, its client was enqueued with WordPress's version appended (`@vite/client?ver=7.1.2`). The modules Vite serves import `/@vite/client` by its bare URL, so the browser loaded the client twice, as two modules with two HMR connections. It is enqueued with no version, like the entries (regression from v13.34.0-beta) + ### Changed - `pollora:make:theme` activates the generated theme only where the site needs one. A site with no usable theme — a first install — gets it without a question; a site that already has one keeps it unless the answer is "yes", now the default "no", so `--no-interaction` never replaces a working theme. `--activate` and `--no-activate` settle it without asking, and `pollora:install` passes `--activate`. Activation goes through `switch_theme()`, which fires `switch_theme` and `after_switch_theme`; the options were written directly before, so those hooks never ran diff --git a/src/Asset/Infrastructure/Services/AssetEnqueuer.php b/src/Asset/Infrastructure/Services/AssetEnqueuer.php index 0d9e3989..f6ad6ab9 100755 --- a/src/Asset/Infrastructure/Services/AssetEnqueuer.php +++ b/src/Asset/Infrastructure/Services/AssetEnqueuer.php @@ -395,7 +395,9 @@ protected function loadViteClient(string $hook): void $url = $this->viteManager instanceof ViteManager ? $this->viteManager->clientUrl() : ''; if ($url !== '') { - wp_enqueue_script_module('vite-client/'.md5($url), $url); + // No version: the modules Vite serves import /@vite/client by its bare URL, + // and a ?ver= copy would be a second client, with its own HMR connection. + wp_enqueue_script_module('vite-client/'.md5($url), $url, [], null); } }, 1); diff --git a/tests/Feature/Asset/AssetEnqueuerTest.php b/tests/Feature/Asset/AssetEnqueuerTest.php index 431e1c7e..de0fb38c 100644 --- a/tests/Feature/Asset/AssetEnqueuerTest.php +++ b/tests/Feature/Asset/AssetEnqueuerTest.php @@ -350,7 +350,8 @@ function viteEnqueuer(ViteManager $viteManager, array $settings = []): AssetEnqu $callback(); expect([$hook, $priority])->toBe(['wp_enqueue_scripts', 1]) - ->and(array_column($this->modules, 'src'))->toBe(['https://site.test:5173/@vite/client']); + ->and(array_column($this->modules, 'src'))->toBe(['https://site.test:5173/@vite/client']) + ->and(array_column($this->modules, 'version'))->toBe([null]); }); });