unplugin-auto-import icon indicating copy to clipboard operation
unplugin-auto-import copied to clipboard

How to rename a variable and continue importing all

Open Kunoky opened this issue 1 year ago • 3 comments

Describe the bug

` //a.js export function a() {} export function b() {} ...

// AutoImport

AutoImport({ imports: [ { 'a.js': [ 'a': 'A' ] } ]

}) ` At this point, b and other variables cannot be imported How to continue importing b and other variables without renaming them?

Reproduction

Perhaps this is not necessary

System Info

win10

Used Package Manager

npm

Validations

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

Kunoky avatar Aug 10 '23 09:08 Kunoky

I am wondering if it would be a good idea to provide a callback that allows users to confirm whether the alias feature is needed. Currently, I am duplicating the configuration for the items that are being used. image

tudou99 avatar Aug 15 '23 09:08 tudou99

I have obtained the configuration information for Vue from unimport and applied some filtering. This is necessary because the h variable is automatically imported into the local package, causing variable conflicts.

const { builtinPresets } = require("unimport");

AutoImport({
  imports: [
    {
      vue: builtinPresets.vue.imports
        .filter((v) => v !== "h")
        .concat([["h", "HAliasName"]]),
    },
  ],
}),

tudou99 avatar Aug 15 '23 10:08 tudou99

I have obtained the configuration information for Vue from unimport and applied some filtering. This is necessary because the h variable is automatically imported into the local package, causing variable conflicts.

const { builtinPresets } = require("unimport");

AutoImport({
  imports: [
    {
      vue: builtinPresets.vue.imports
        .filter((v) => v !== "h")
        .concat([["h", "HAliasName"]]),
    },
  ],
}),

Thank you, but this is essentially exhaustive and does not have universality

Kunoky avatar Aug 18 '23 05:08 Kunoky