Skip to content

Conversation

@kevinmarrec
Copy link
Contributor

@kevinmarrec kevinmarrec commented Apr 24, 2020

Multiple dirs support which each having :

  • required path -> Where to look for components
  • optional pattern (default: '**/*.{builder.supportedExtensions}')
  • optional ignore (default: patterns ignored by default by nuxt (.nuxtignore, tests, etc..))
  • optional prefix (default: '') -> Add prefix to component names
  • optional watch option (default: true) -> Watch directory for changes
  • optional transpile option (default: false) -> Transpile directory (build.transpile)

Dynamic imports (lazy loading) support (with lazy prefix)

Top level options (components key in config)

TODO

  • Update docs

@kevinmarrec kevinmarrec changed the title feat: patterns array, lazy & duplicates support feat: multiple dirs, prefix, watch & transpile support Apr 25, 2020
@kevinmarrec kevinmarrec requested review from atinux and pi0 April 25, 2020 17:49
@kevinmarrec
Copy link
Contributor Author

kevinmarrec commented Apr 25, 2020

=> Tested on my work app

image

Sounds there is a condition that is not met in my work app to have builder.ignore.ignore existing.

Investigating...

@kevinmarrec
Copy link
Contributor Author

kevinmarrec commented Apr 25, 2020

EDIT : Found the issue, it's cause I'm using nuxt-edge for nuxt/components, and there has been a change nuxt/nuxt#7132 not released on 2.x yet.

So builder.ignore.ignore is undefined if there isn't .nuxtignore on Nuxt <= 2.12.

Gonna just add checks to fix it :)

Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicee works!

@kevinmarrec
Copy link
Contributor Author

@pi0 Thanks for the detailed review, will do updates accordingly 😊

@kevinmarrec kevinmarrec requested a review from pi0 April 27, 2020 19:28
@atinux
Copy link
Member

atinux commented Apr 27, 2020

Awesome work @kevinmarrec

One question, what if I want:

  • components/bases/ -> prefix with Base
  • components/icons/ -> prefix with Icon
  • components/ -> no dir prefix (all the others)

Should this work?

export default {
  components: [
     { path: '@/components/bases/', prefix: 'Base' },
     { path: '@/components/icons/', prefix: 'Icons' },
     '@/components')
  ]
}

While avoiding to register @/components/bases/ and @/components/icons without prefixes?

@pi0
Copy link
Member

pi0 commented Apr 27, 2020

@atinux Nice challenge :p

I think we can easily satisfy that by:

  • Sorting directories to scan by their path* length (so parents are always after childs)
  • Skip components that were already discovered
  • paths may be better to prerolved so all are absolute

@kevinmarrec
Copy link
Contributor Author

@atinux Indeed nice challenge 😁
@pi0 Makes sense and thanks for the hints.

Yep I can sort directly after paths are resolved with Nuxt resolvePath, so that's path length is calculated based on absolute path here.

And indeed then make the scanning function skip files that already have been handled by previous loops on other child paths :)

@kevinmarrec
Copy link
Contributor Author

image

@kevinmarrec kevinmarrec merged commit f4e5972 into master Apr 28, 2020
@kevinmarrec kevinmarrec deleted the new-features branch April 28, 2020 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants