dipeshsukhia / laravel-html-minify

laravel minify html output
MIT License
66 stars 22 forks source link

view:cache command error in v3.3.4 #19

Closed RChutchev closed 4 months ago

RChutchev commented 4 months ago

Hello, there is a problem with the new v3.3.4.

I'm getting an error with php8.2 artisan view:cache command.

After the package is upgraded to the new version (Upgrading dipeshsukhia/laravel-html-minify (v3.3.3 => v3.3.4)), I get an error with the dynamic component, after downgrading back to v.3.3.3, the error is gone. I mean with the previous version, the command was executed successfully INFO Blade templates cached successfully.. I checked twice.

I'm not sure what exactly goes on here, and why after your package upgraded Filament's related component 'dynamic-component' is unavailable, anyway can you help me with that, please?

PHP 8.2.0 Laravel 10.48.13 Filament 2.17.56

 InvalidArgumentException 

  Unable to locate a class or view for component [dynamic-component].

  at vendor/laravel/framework/src/Illuminate/View/Compilers/ComponentTagCompiler.php:311
    307▕         if (Str::startsWith($component, 'mail::')) {
    308▕             return $component;
    309▕         }
    310▕ 
  ➜ 311▕         throw new InvalidArgumentException(
    312▕             "Unable to locate a class or view for component [{$component}]."
    313▕         );
    314▕     }
    315▕ 

      +2 vendor frames 

  3   [internal]:0
      Illuminate\View\Compilers\ComponentTagCompiler::Illuminate\View\Compilers\{closure}()
      +8 vendor frames 

  12  [internal]:0
      Illuminate\Foundation\Console\ViewCacheCommand::Illuminate\Foundation\Console\{closure}(Object(Symfony\Component\Finder\SplFileInfo), "/Users/rchutchev/SERVER/redsealine.local/links/resources/views/filament/forms/components/image.blade.php")

The file contains this code

@php
    /**
    * @var $getDatalistOptions
    * @var $errors
    * @var $getStatePath
    * @var $getState
    **/

    $datalistOptions = $getDatalistOptions();

    $affixLabelClasses = [
        'whitespace-nowrap group-focus-within:text-primary-500',
        'text-gray-400' => ! $errors->has($getStatePath()),
        'text-danger-400' => $errors->has($getStatePath()),
    ];
@endphp

<x-dynamic-component
    :component="$getFieldWrapperView()"
    :id="$getId()"
    :label="$getLabel()"
    :label-sr-only="$isLabelHidden()"
    :helper-text="$getHelperText()"
    :hint="$getHint()"
    :hint-action="$getHintAction()"
    :hint-color="$getHintColor()"
    :hint-icon="$getHintIcon()"
    :required="$isRequired()"
    :state-path="$getStatePath()"
>
    <div
        {{
            $attributes
                ->merge($getExtraAttributes())
                ->class(['filament-forms-text-input-component group flex items-center space-x-2 rtl:space-x-reverse'])
        }}
    >
        @if (($prefixAction = $getPrefixAction()) && (! $prefixAction->isHidden()))
            {{ $prefixAction }}
        @endif

        @if ($icon = $getPrefixIcon())
            <x-dynamic-component :component="$icon" class="h-5 w-5" />
        @endif

        @if (filled($label = $getPrefixLabel()))
            <span @class($affixLabelClasses)>
                {{ $label }}
            </span>
        @endif

        <div class="flex-1">
            @php
                if($getState()){
                    $regex = preg_match("/(?i)\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))/", $getState());
                    if ($regex){
            @endphp
            <img src='{{ $getState() }}' size="" class="rounded-full" alt="{{ $getState() }}" />
            @php
                } else {
            @endphp
            <img src='/storage/{{ $getState() }}' size="" class="rounded-full" alt="{{ $getState() }}" />
            @php
                }
            }
            @endphp
        </div>

        @if (filled($label = $getSuffixLabel()))
            <span @class($affixLabelClasses)>
                {{ $label }}
            </span>
        @endif

        @if ($icon = $getSuffixIcon())
            <x-dynamic-component :component="$icon" class="h-5 w-5" />
        @endif

        @if (($suffixAction = $getSuffixAction()) && (! $suffixAction->isHidden()))
            {{ $suffixAction }}
        @endif
    </div>

    @if ($datalistOptions)
        <datalist id="{{ $getId() }}-list">
            @foreach ($datalistOptions as $option)
                <option value="{{ $option }}"></option>
            @endforeach
        </datalist>
    @endif
</x-dynamic-component>
RChutchev commented 4 months ago

@dipeshsukhia please participate

dipeshsukhia commented 4 months ago

review changes for version 3.3.4 It looks good and the issue does not occur for any artisan command.

RChutchev commented 4 months ago

@dipeshsukhia, I'm sorry, but it looks like you missed something, I appreciate your work, but I'm getting this error for both (test and prod) environments. When I rollbacked the package to the previous version everything worked fine, but after upgrading to the new version I'm getting this error. Screenshot 2024-06-22 at 6 28 37 PM

RChutchev commented 4 months ago

Here are no errors in ver. 3.3.3, but in 3.3.4 I'm getting this error, I'm not sure that this problem is Laravel-related b/c only your plugin upgrade caused this error, that's a real problem for us b/c we're using caching for website performance, you know and minification is required for the same reason, and I can't understand what is cause this error. How is 'dynamic-component' connected with your modification plugin, I'll check out, how to bypass this problem later, but maybe you can help me understand which modification in the new version of your package can cause this issue without code research/investigation from my side with your plugin code?