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

'/node_modules/.vite/deps/vuetify_lib.js?v=5b28369c' does not provide an export named Vjsf issue #439

Open
aloksingh3112 opened this issue Jun 29, 2022 · 2 comments

Comments

@aloksingh3112
Copy link

I was using @koumoul/vjsf library in my project and recently I migrate from weback to vite , I am getting this issue that Vjsf library trying to resolve through vuetify resolver . Not able to find any solution for this

vite.config.js

import { createVuePlugin } from "vite-plugin-vue2"
import Components from "unplugin-vue-components/vite"
import { VuetifyResolver } from "unplugin-vue-components/resolvers"
import resolveExtensionVue from "vite-plugin-resolve-extension-vue"
// import vuetifyLoader from "vite-plugin-vuetify"

import path from "path"

/**
 * @type {import('vite').UserConfig}
 */
export default () => {
	// eslint-disable-next-line
	require("dotenv").config()
	return {
		resolve: {
			extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
			alias: [
				{
					find: "@/",
					replacement: `${path.resolve(__dirname, "./src")}/`,
				},
				{
					find: "src/",
					replacement: `${path.resolve(__dirname, "./src")}/`,
				},
			],
		},
		// extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
		plugins: [
			createVuePlugin(),
			resolveExtensionVue(),
			// vuetifyLoader({ autoImport: true }),
			Components({
				resolvers: [VuetifyResolver()],
			}),
		],
		server: {
			port: 8080,
		},
		define: {
			"process.env": process.env,
		},
	}
}

@azaleta
Copy link
Contributor

azaleta commented Jun 29, 2022

your resolvers defination contains VuetifyResolver only, so only VuetifyResolver will work.
According to Vuetify Resolver

export function VuetifyResolver(): ComponentResolver {
  return {
    type: 'component',
    resolve: (name: string) => {
      if (name.match(/^V[A-Z]/))
        return { name, from: 'vuetify/lib' }
    },
  }
}

Vjsf could not found in Vuetify lib => get this error

resolve process is the first matching one works

 async findComponent(name: string, type: 'component' | 'directive', excludePaths: string[] = []): Promise<ComponentInfo | undefined> {
    // resolve from fs
    let info = this._componentNameMap[name]
    if (info && !excludePaths.includes(info.from) && !excludePaths.includes(info.from.slice(1)))
      return info

    // custom resolvers
    for (const resolver of this.options.resolvers) {
      if (resolver.type !== type)
        continue

      const result = await resolver.resolve(name)
      if (result) {

so I think you could make your own resolver and put it as the first item
something like
vite.config.js

Components({
  resolvers: [
    (componentName) => {
      if (componentName.startsWith('Vjsf'))  //do not know the UI lib naming rule
        return { name: componentName, as:componentName, from: '@koumoul\vjsf\lib'}
    },
    VuetifyResolver()
  ],
})

hope it works

@isramos
Copy link

isramos commented Aug 20, 2022

That worked for me. Thanks a lot!

I had to do couple minor fixes:

  • Capitalization: 'VJsf' instead of 'Vjsf'
  • Path: '@koumoul/vjsf' instead '@Koumoul\vjsf\lib'

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

No branches or pull requests

3 participants