Skip to content

resolver not called when isCustomElement is set #904

@robin-ln

Description

@robin-ln

Describe the bug

I use a design system that exposes web components and I want unplugin-vue-components to auto-import these components via a custom resolver. To avoid a runtime rendering error from Vue with the web components, I had to define the isCustomElement function in the Vue compiler options.

When I enable isCustomElement (so Vue treats ux-* tags as custom elements), the resolver for unplugin-vue-components no longer appears to be invoked.

Reproducing configuration

import { defineConfig } from 'vitest/config';
import vue from '@vitejs/plugin-vue';
import Components from 'unplugin-vue-components/vite';
import path from 'node:path';

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: (tag: string) => tag.startsWith('ux-'), // comment and un comment this line
        },
      },
    }),
    Components({
      resolvers: [
        (name: string) => {
          if (name.startsWith('Ux')) {
            return {
              name,
              from: `@mylib/${name}`,
            };
          }
        },
      ],
      globs: 'src/**/*.vue',
    }),
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
});

Expected behavior

  • The resolver should be called, even when isCustomElement is set so that Vue does not transform ux-* tags into Vue components.

Actual behavior

  • When isCustomElement is set no longer appears: the resolver is not invoked.

Reproduction

https://stackblitz.com/edit/vitejs-vite-yqwafxpa

System Info

npx envinfo --system --binaries --browsers
Need to install the following packages:
envinfo@7.21.0
Ok to proceed? (y) y


  System:
    OS: Linux 5.0 undefined
    CPU: (6) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:

Used Package Manager

npm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

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