Repository navigation
Import autocomplete in VS Code ends in undefined for .vue files distributed as source code in npm package #6202
Replies: 1 comment
|
I asked Claude to lay out my solution in a straightforward, step-by-step manner, so this should be pretty easy to follow. Let me know if you need any extra help. 1. The guard. In for (const vueExt of vueOptions.extensions) {
const suffix = capitalize(vueExt.slice(1)); // .vue -> Vue
if (item.source.endsWith(vueExt) && item.name.endsWith(suffix)) {
item.name = capitalize(item.name.slice(0, -suffix.length));
…
data.__vue__componentAutoImport = { oldName, newName };
break;
}
}When that 2. That's why you keep 3. And that's why 4. Where the 5. What would pin the trailing 6. Something you can do today, on the library side. Give the package a real |
Uh oh!
There was an error while loading. Please reload this page.
At my job, we have an npm package that contains Vue components in the form of .vue SFC files that are distributed as source code (no bundling, no compiling, just the .vue files as-is). In a consuming project, the auto completion suggestion for adding the appropriate imports while typing in a component's template section behaves strangely for this package:
Consider the following file in the consuming project and that
node_modules/my-component-librarycontains the filePackageIcon.vue:Test.vue:This will show one completion suggestion: PackageIconVue. Accepting it leads to the following change:
Test.vue:Now, I've found issues and discussions here talking about the additional
Vuestring in the imported symbol and while I'd preferPackageIcon, it doesn't cause any real issues.However, how come the import path contains
undefinedat the end?This only seems to happen for Vue components that are discovered in
node_modules/via package module specifiers. Imports local to the project work fine and also don't append theVuestring.Also, when I use TypeScript (i.e.
lang="ts"), the import is further broken by the addition of thetypekeyword:Test.vue:Though strangely, this doesn't always reproduce.
I wanted to raise this as a discussion first because I'm not sure if this is an environment problem and not a bug. Also, I can't really offer a reproduction as the library is private.
All reactions