spatie / laravel-blade-comments

Add debug comments to your rendered output
https://freek.dev/2500-a-laravel-package-to-quickly-see-which-html-is-rendered-by-which-blade-view
MIT License
150 stars 9 forks source link

[Bug]: Blade Comments "AnonymousBladeComponentCommenter" breaks Laravel Pulse #21

Open xHeaven opened 7 months ago

xHeaven commented 7 months ago

What happened?

The package breaks Laravel Pulse's interface. See more here: https://github.com/laravel/pulse/issues/91

How to reproduce the bug

Install Laravel Pulse (currently v1.0.0-beta5), then install this package (currently v1.2.2), enable the AnonymousBladeComponentCommenter and visit your.app/pulse.

Package Version

1.2.2

PHP Version

8.3.0

Laravel Version

10.35.0

Which operating systems does with happen with?

macOS, Windows, Linux

Notes

No response

timvandijck commented 7 months ago

This looks like a hard one one to solve. It seems to be that the anonymous components are used at the root level of the Livewire components, which breaks things. If I edit AnonymousBladeComponentCommenter and wrap the comment in a div the error goes away, but the styling is messed up.

I don't believe there's a way to check if the component is being used in a Livewire component at the stage where we add the comment.

The best solution might be that I extend the exludes functionality and add the Pulse namespace as a default to exclude when adding comments to anonymous components. Not ideal, but at least it would stop breaking Pulse.

spatie-bot commented 2 months ago

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

johnbacon commented 1 month ago

We're also experiencing this issue and cannot figure out how to disable laravel-blade-comments for just Laravel Pulse.

Any tips on how we might go about doing that? The following doesn't do the trick:

    /*
     * Do not add comments to the output of these directives.
     */
    'excludes' => [
        'includes' => [
            'vendor.pulse.dashboard', // TODO: Disable for Pulse. This does not seem to work.
        ],
    ],