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

自动引入,引入出现错误 #505

Closed
PDB6912 opened this issue Sep 2, 2022 · 10 comments · Fixed by #554
Closed

自动引入,引入出现错误 #505

PDB6912 opened this issue Sep 2, 2022 · 10 comments · Fixed by #554

Comments

@PDB6912
Copy link

PDB6912 commented Sep 2, 2022

//types.ts
export const enum Flow {
  'START_NODE' = 'START_NODE', 
}

//test.vue
impor {Flow} from './types;
import { reactive } from 'vue';
const data = reactive({
  kind : Flow.START_NODE
})

run的时候,auto-imports.d会自动添加 const TART_NODE: typeof import('tdesign-vue-next')['ART_NODE']

终端就会报Internal server error: Failed to resolve import "tdesign-vue-next/es/a-r-t_-n-o-d-e/style" from "src\models\flownodedesigner\flownodedesigner.ts". Does the file exist

看了下https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/tdesign.ts,也没明白为什么出现这样的问题,name.match(/^T[A-Z]/  name是怎么获取的
@azaleta
Copy link
Contributor

azaleta commented Sep 5, 2022

https://github.com/antfu/unplugin-vue-components/blob/cb8f9325ffdaeb74927d823095a30d2ec9a262a9/src/core/utils.ts#L28

suppose you using a component name with full uppercase.
This is out of range.

normally, a compont name like TartNode will be splitted with Uppercase (T/N) then combine with - -> Tart-Node -> toLowercase
In your case, TART_NODE will transform to a-r-t_-n-o-d-e

Also, seems TART_NODE is not a tdsign component as well.
use your own resolver pls

@sxzz sxzz closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2022
@sxzz
Copy link
Member

sxzz commented Sep 6, 2022

It seems to be a bug, please provide a minimum reproduction repo.
https://antfu.me/posts/why-reproductions-are-required-zh

@sxzz sxzz reopened this Sep 6, 2022
@PDB6912
Copy link
Author

PDB6912 commented Sep 7, 2022

我这个并不是个组件,但是被解析了

@azaleta
Copy link
Contributor

azaleta commented Sep 7, 2022

name.match(/^T[A-Z]/

your own code 'TART_NODE' matchs the naming rule(start with T)
that will trigger the tdesign process.

@PDB6912
Copy link
Author

PDB6912 commented Sep 23, 2022

我的code是START_NODE ,是S开头的啊

@PDB6912
Copy link
Author

PDB6912 commented Sep 23, 2022

'TART_NODE'这个code在我代码里都没出现出现过

@PDB6912
Copy link
Author

PDB6912 commented Sep 23, 2022

每次出现这个问题,都是我是用类似样式 a.THE 或者 a.STHE,使用对象属性,为什么会被当做引入呢

@PDB6912
Copy link
Author

PDB6912 commented Sep 23, 2022

const a = {
TA: '1'
}

let a: any = {}
a.STA = '1'

const a = {
STA: '1'
}
a.STA
都会报同样的错误

@Sight-wcg
Copy link
Contributor

unplugin-vue-components 插件只解析模板中的内容,unplugin-auto-import 插件会解析 script 中的内容,你可以尝试移除 auto-import 中配置的 TDesignResolver

@PDB6912
Copy link
Author

PDB6912 commented Sep 27, 2022

好的,谢谢

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

Successfully merging a pull request may close this issue.

4 participants