Optimizing directory with `Blaze::optimize()->in()` renders class-based templates as empty output
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 745
- Forks
- 39
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 6
Description
Describe the bug
Blaze::optimize()->in() compiles every template in it's target directory, with no way to know
which ones a class will later render.
If the target directory contains any class-based templates they render as empty strings + no exception + 200 response.
By default Laravel's make:component also writes class-based templates to
resources/views/components (same directory Blaze README uses to illustrate optimizing by directory.)
Reproduce
php artisan make:component Alert(no flags, class-based)- Class: add
public string $message - Template:
<div>{{ $message }}</div> - Provider:
Blaze::optimize()->in(resource_path('views/components')); php artisan view:clear- Render
<x-alert message="hello" />
Result
Same component & input, toggling only BLAZE_ENABLED:
false -> <div>hello</div>
true -> (empty, no exception)
Cause
Compiled artefact for the class-based component's template:
<?php
if (!function_exists('_1365a3bc689a48ca5ab34037d510a76f')):
function _1365a3bc689a48ca5ab34037d510a76f($__blaze, $__data = [], ...) {
// ...
echo ltrim(ob_get_clean());
} endif; ?>
<?php /**PATH .../components/blaze-repro.blade.php ENDPATH**/ ?>
Component::render() returns a view, then CompilerEngine::get() and
PhpEngine::evaluatePath() require the file and capture output. Function defined,
nothing printed, Blaze runtime never invoked.
Not covered by #146
#146 handled tag resolution, adding a class check inside componentNameToPath() so it
returns '' for class-based names and a Blaze parent won't inline <x-alert>.
This is file compilation instead. The pre-compilation hook wraps every Blaze::optimize()->in() template regardless of what renders it, and no tag is involved. Reproduced on v1.0.18, which includes #146.
Environment
Laravel 13.31.0, PHP 8.4.6, livewire/blaze v1.0.18
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with php artisan make:component Alert, Blaze::optimize()->in(resource_path('views/components')), and the <x-alert> render, then trace the pre-compilation hook through Component::render(), CompilerEngine::get(), and PhpEngine::evaluatePath(). Done means class-based templates in the optimized directory render normally with BLAZE_ENABLED while Blade-only templates remain optimized.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 67/100