From db179e6b4e380bbd6aba2d3766ffcc84e58a8dd2 Mon Sep 17 00:00:00 2001 From: Andreas Reinhold / reini Date: Sun, 13 Sep 2026 17:40:33 +0200 Subject: [PATCH] Compile the showcase's views with the showcase off php artisan view:cache compiles every view in the package's namespace, the showcase's pages included, but the showcase:: component prefix was only registered while the showcase was enabled. In production, where it is off, view:cache failed with "Unable to locate a class or view for component [showcase::example]" and an application caching its views on start would not boot. The prefix is now always registered; the routes still are not. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy --- src/LivewireMaterialServiceProvider.php | 6 ++++-- tests/Feature/ShowcaseTest.php | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/LivewireMaterialServiceProvider.php b/src/LivewireMaterialServiceProvider.php index 49e6604c..1df3de15 100644 --- a/src/LivewireMaterialServiceProvider.php +++ b/src/LivewireMaterialServiceProvider.php @@ -175,12 +175,14 @@ class LivewireMaterialServiceProvider extends ServiceProvider */ protected function registerShowcase(): void { + // Registered even with the showcase off: `php artisan view:cache` compiles every view in the + // package's namespace, the showcase's pages included, and must resolve there. + Blade::anonymousComponentPath(__DIR__.'/../resources/views/showcase/components', 'showcase'); + if (! config('livewire-material.showcase.enabled')) { return; } - Blade::anonymousComponentPath(__DIR__.'/../resources/views/showcase/components', 'showcase'); - if ($this->app->routesAreCached()) { return; } diff --git a/tests/Feature/ShowcaseTest.php b/tests/Feature/ShowcaseTest.php index 5e977f43..3f340746 100644 --- a/tests/Feature/ShowcaseTest.php +++ b/tests/Feature/ShowcaseTest.php @@ -71,6 +71,20 @@ it('does not mount the showcase when disabled', function () { $this->get('/material')->assertNotFound(); }); +it('compiles every package view with the showcase off, as view:cache does in production', function () { + rebootWithShowcase(false); + + $compiled = sys_get_temp_dir().'/livewire-material-view-cache-'.uniqid(); + config(['view.compiled' => $compiled]); + File::ensureDirectoryExists($compiled); + + try { + $this->artisan('view:cache')->assertSuccessful(); + } finally { + File::deleteDirectory($compiled); + } +}); + it('serves a symbol for the icon search', function () { $this->get('/material/symbols/filled/favorite.svg') ->assertOk()