Skip to content

Build A Manifest File Instead Of Manual Component Registration #15

@nickpoulos

Description

@nickpoulos

Really awesome project, can't wait to try this out in a more official capacity. Thank you for creating it.

But I did notice one thing that could be improved upon.

I mentioned in another comment I wrote a Laravel package for Svelte that has many similar problems to solve. My package compiles each Svelte component in your project into bite sized js file, and then loads that file automatically if you use the tag in blade.

So we need to map Blade HTML tags to these compiled JS files. You have to do the same for Blade tags and PHP files, as does Livewire.

I looked at several other projects as inspiration:

  • Spatie's BladeX package (which serves as the foundation for Laravel's Blade Components)
  • Laravel's Blade Components
  • Livewire

There are three main approaches here:

1. Having the user define these mappings in a ServiceProvider

  • The approach Spatie Blade X and Airwire took
  • The easiest to implement, yet the most annoying for the user.

2. Use a Naming Convention, Standard Locations, Etc.

  • Laravel Blade Components basically took Spatie BladeX, but then added a naming convention on top
  • By prefixing an x- in front of the component name, and doing some Studly/Camel-case conversion, Laravel knows to check the /resources/views/components folder

3. Build A Manifest File Automatically

  • This is the approach Livewire takes, and the approach I stole for my package
  • The user doesn't have to define the components in a ServiceProvider
  • The package generates a manifest file that loads the component-to-tag mappings
  • Check out bootstrap/cache/livewire-components.php

I would love to see Airwire use the manifest approach outlined above and remove that annoying middle step for the user.

Happy to help implement/submit a PR.

Have you considered this at all? See any downsides?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions