fix: 拆分es和commonjs

This commit is contained in:
2023-07-13 10:20:54 +08:00
parent 86c9e7d6f1
commit d60f583aef
3 changed files with 38 additions and 8 deletions

8
utils/resolver.d.ts vendored
View File

@ -6,11 +6,9 @@
* @FilePath: \uni\utils\resolver.d.ts * @FilePath: \uni\utils\resolver.d.ts
* @Description: * @Description:
* *
*/ */
declare const _default: (name: string) =>({ export const resolverThzxcx: (name: string) =>({
name: string; name: string;
as: string; as: string;
from: string; from: string;
}) })
export default _default

View File

@ -1,8 +1,8 @@
/* /*
* @Author: zhaojinfeng 121016171@qq.com * @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-06-25 10:56:32 * @Date: 2023-06-25 10:56:32
* @LastEditors: peerless_hero peerless_hero@outlook.com * @LastEditors: zhaojinfeng 121016171@qq.com
* @LastEditTime: 2023-07-13 04:11:50 * @LastEditTime: 2023-07-13 10:20:10
* @FilePath: \uni\utils\resolver.js * @FilePath: \uni\utils\resolver.js
* @Description: 自动导入组件的解析器 * @Description: 自动导入组件的解析器
* *
@ -20,7 +20,7 @@ function toLower(name) {
return lower return lower
} }
export default function (name) { module.exports.resolverThzxcx = function (name) {
if (name.startsWith('Th')) { if (name.startsWith('Th')) {
const componentName = toLower(name.slice(2)) const componentName = toLower(name.slice(2))
return { return {

32
utils/resolver.mjs Normal file
View File

@ -0,0 +1,32 @@
/*
* @Author: zhaojinfeng 121016171@qq.com
* @Date: 2023-06-25 10:56:32
* @LastEditors: peerless_hero peerless_hero@outlook.com
* @LastEditTime: 2023-07-13 04:11:50
* @FilePath: \uni\utils\resolver.js
* @Description: 自动导入组件的解析器
*
*/
const reg = /[A-Z]/
function toLower(name) {
let lower = ''
for (let i = 0; i <= name.length - 1; i++) {
if (reg.test(name[i]))
lower += `-${name[i].toLowerCase()}`
else
lower += name[i]
}
return lower
}
export default function resolverThzxcx(name) {
if (name.startsWith('Th')) {
const componentName = toLower(name.slice(2))
return {
name: 'default',
as: name,
from: `@thzxcx/uni/es/${componentName}/index.vue`,
}
}
}