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

feat: add unplugin-vue-components and unimport integration #20536

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from

Conversation

userquin
Copy link
Member

@userquin userquin commented Sep 29, 2024

Description

This PR includes:

  • unimport presets for Vuetify composables and directives and Vuetify One composables
  • unplugin-vue-components resolvers for Vuetify components and directives
  • update unimport and unplugin-auto-import to latest versions (3.13.1 and 0.18.3 respectively)
  • docs: replace inlined auto import presets for Vuetify and Vuetify One composables
  • docs: add Vuetify Directives preset to allow Volar suggest them: right now we need feat(vue): add auto-import directives unplugin/unplugin-auto-import#534 merged and released
  • add unbuild to build the new new subpackages exports (node stuff): I have no idea how to configure/call unbuild with custom build.config.mts configuration file, right now using build.config.mts in vuetify package root, should be moved to build folder: should be fixed with this PR feat: add --config to the CLI unjs/unbuild#440 (it should be ported to v2 or update here to use v3-rc version)
  • add some jsdocs to Rollup configuration files and extract some constants to its own module: now we have types inside the mjs modules.
  • add vuetify/unimport and vuetify/unplugin-vue-components to package exports and typesVersions
  • remove auto import logic in vuetify playground: use unplugin-vue-components to auto import components, lab components and directives: reverted since the CI test process hangs (I need to review Vite playground configuration)

We need to add these 2 new integrations somewhere in the docs.

Note

We need to review the lint script, right now I excluded packages/vuetify/src/unplugin from the tsconfig.dist.json file to allow build vuetify.

Note

Maybe we should add a new package or move this PR to another repository.

Tip

  • vuetify/unplugin-vue-components: will resolve components and directives: the directives will be missing from the Vue module augmentation and so Volar will not suggest Vuetify directives in the Vue templates. vuetify/unplugin-vue-components won't be able to auto import Vuetify composables.
  • vuetify/unimport via unplugin-auto-import: will auto import Vuetify composables and directives and won't be able to auto import Vuetify components. vuetify/unimport will add Vuetify directives in the Vue module augmentation to allow Volar suggest them in the Vue templates (when feat(vue): add auto-import directives unplugin/unplugin-auto-import#534 merged and released).
  • vite-plugin-vuetify: same behavior vuetify/unplugin-vue-components. vite-plugin-vuetify adds Vuetify SASS variables support.
  • vuetify-nuxt-module: will use vuetify/unimport to auto-import Vuetify composables and directives (requires this PR feat(nuxt,schema): add directives folder nuxt/nuxt#29203 merged and released) and will use Nuxt internal components loader to load Vuetify components (requires this PR feat!: use Nuxt components loader instead custom Vite plugin nuxt-module#276 merged and released). Since it will use vuetify/unimport, Vuetify directives will be suggested by Volar in Vue templates. vuetify-nuxt-module adds Vuetify SASS variables support via custom styles Vite plugin.

johnleider
johnleider previously approved these changes Sep 30, 2024
@johnleider johnleider changed the title feat: add unplugin-vue-components and unimport integration docs: add unplugin-vue-components and unimport integration Sep 30, 2024
@KaelWD KaelWD changed the title docs: add unplugin-vue-components and unimport integration feat: add unplugin-vue-components and unimport integration Sep 30, 2024
@KaelWD KaelWD added this to the v3.8.0 (Andromeda) milestone Sep 30, 2024
@KaelWD KaelWD added T: feature A new feature and removed T: documentation labels Sep 30, 2024
@@ -0,0 +1,94 @@
import { defineBuildConfig } from 'unbuild'
Copy link
Member

Choose a reason for hiding this comment

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

Why are you using a separate build process for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

We must split client and node builds, I can move it to rollup but I like unbuild.

Copy link
Member Author

Choose a reason for hiding this comment

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

done:

  • added some jsdocs to rollup config files to have auto complettion and suggestions in the ide
  • removed unbuild and moved unplugin/*.ts build to Rollup
  • fixed also the lint script: added rootDir and custom exclude in tsconfig.check.json

@userquin
Copy link
Member Author

userquin commented Oct 1, 2024

I'm going to split this pr to add jsdocs annotations to rollup config and add hanging-process reporter in vitest configuration.

I didn't check Vitest using Vuetify Vite playground configuration: reverted changes and CI green.

@userquin userquin requested a review from KaelWD October 1, 2024 09:34
@KaelWD KaelWD changed the base branch from master to dev January 22, 2025 06:12
@KaelWD KaelWD self-assigned this Jan 22, 2025
return JSON.parse(await readFile(path.resolve(vuetifyBase, 'dist/json/importMap.json'), 'utf-8'))
}
async function importMapLabs (vuetifyBase: string): Promise<ImportLabsComponents> {
return JSON.parse(await readFile(path.resolve(vuetifyBase, 'dist/json/importMap-labs.json'), 'utf-8'))
Copy link
Member Author

@userquin userquin Jan 22, 2025

Choose a reason for hiding this comment

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

It will be better to add importMap.json and importMap-labs.json to package exports, this change will allow use dynamic import instead resolving vuetify base and reading the file (or just use dynamic import via vuetify/dist/json/importMap.json or vuetify/dist/json/importMap-labs.json).

Copy link
Member

Choose a reason for hiding this comment

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

We're using readFile here because node 20 logs a warning for import attributes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants