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
162 stars 9 forks source link

[Bug]: Using this in conjunction with Livewire mess up the SupportAlpine.js #6

Open sawirricardo opened 1 year ago

sawirricardo commented 1 year ago

What happened?

After installation, I noticed that in the browser console it outputs an error of wireEl is undefined.

How to reproduce the bug

Just install this package in a livewire project, preferable with Filament's admin package. And see the browser console.

composer create-project laravel/laravel test;
composer require filamentphp/filament;
composer require spatie/laravel-blade-comments;

Then go through the browser console and see the error

Package Version

1.0.1

PHP Version

8.2.0

Laravel Version

10.13.0

Which operating systems does with happen with?

macOS

Notes

Filament ......................................................
Packages ...... filament, forms, notifications, support, tables
Version .............................................. v2.17.44
Views ..................................... PUBLISHED: filament

timvandijck commented 1 year ago

@sawirricardo I just tried this in a fresh project with Filament but I don't seem to get the error you described. Is there anything you can think off that will help me reproduce the error?

sawirricardo commented 1 year ago

Hem, How about this?

composer create-project laravel/laravel test;
composer require filamentphp/filament;
composer require spatie/laravel-blade-comments --dev;

php artisan migrate:fresh --seed;

Then try to access https://example.com/admin (will be redirected to login) and see the browser output (notice the SupportAlpine.js, addDollarSignWire error)

Here's mine

image

The only way is to.... remove this package... And even then will require to php artisan optimize:clear

satoved commented 1 year ago

Can confirm, even disabling the blade comments package in config doesn't help.

timvandijck commented 1 year ago

@sawirricardo thank you for the extra info! I'm now also able to replicate it.

I'm still not entirely sure what's exactly going wrong. The problem seems to be more specific the combination of Filament and the AnonymousBladeComponentCommenter from our package but I haven't been able to pinpoint the exact component that is causing the proble.

The solution could be as simple as refining the regex for this commenter, but I don't really have time to go all the way down through the Filament rabit hole. If someone has time to find the exact component that is causing the problem I'de be happy to have an other look.

For now I would advice to publish the config file for this package and comment out the AnonymousBladeComponentCommenter. This should still give you blade comments for all other types of components while resolving the issue you are having.