Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to Lazy* prefix #180

Open
pi0 opened this issue Apr 6, 2021 · 8 comments
Open

Alternative to Lazy* prefix #180

pi0 opened this issue Apr 6, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@pi0
Copy link
Member

pi0 commented Apr 6, 2021

As mentioned by @dmx374 (#83), using Lazy prefix might be confusing in situations when the component name is prefixed with Lazy for its purpose (LazyLoad, LazySpin, etc).

We cannot use directives since it forces to use a loader and parsing overhead but we can introduce another alias while keeping backward compatibility with Lazy{name}. Some options:

  • Async{Name} / async-{name}
  • {Name}.lazy / {name}.lazy (suggested by @drewbaker)
  • {Name}.async / {name}.async
@pi0 pi0 added the enhancement New feature or request label Apr 6, 2021
@pi0
Copy link
Member Author

pi0 commented Apr 6, 2021

/cc @nuxt/framework ideas welcome

@clarkdo
Copy link
Member

clarkdo commented Apr 6, 2021

+1 for async for aligning to Vue async component
https://v3.vuejs.org/guide/migration/async-components.html#_3-x-syntax
https://v3.vuejs.org/guide/component-dynamic-async.html#async-components

@pi0
Copy link
Member Author

pi0 commented Apr 6, 2021

@clarkdo You mean <Async{Name}> option? It makes sense to be consistent with vue docs.

@clarkdo
Copy link
Member

clarkdo commented Apr 6, 2021

Yes

@drewbaker
Copy link

Maybe I’m misunderstand async components, but isn’t there lots of scenarios where a component can be used in different places, sometimes async and sometimes not? So by using the filename as the way to detect if it’s async or not seems like the wrong approach? Or is this the only way?

The Vue guide also recommend tightly coupled components to have related names, like “CarsList” and “CarsListItem”, so by forcing “Async” at the start of the component you’ll be loosing that coupling.

I just suspect people hate being forced to have any word in their component file name, no matter what you pick. That’s why I prefer the modifier Name.async.vue, feel more “nuxt” (like the way plugin file names can have client or server in them).

@pi0
Copy link
Member Author

pi0 commented Apr 8, 2021

@drewbaker That's true and you do don't need to prefix your component file name with either Lazy or Async 🙈 It should be called Foo.vue. <LazyFoo> is an alias to tell import Foo.vue as an async component.

@drewbaker
Copy link

Oh Ok I’m that case AsyncFoo seems great!

@Bigdragon13th
Copy link

@pi0 I come across this issue since I just found out Nuxt having this as default now on new projects setup. And looking in the doc I too thought I have to rename my component Lazy{Name} to make it lazy load, I'm happy it's not the case. Maybe clarify this in doc would help?

@pi0 pi0 mentioned this issue Jul 8, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants