Closed G1King closed 1 year ago
function getSideEffectsLegacy(partialName, options) {
const { importStyle } = options
if (!importStyle) return
const themeFolder = 'bc-element/theme-chalk'
if (importStyle === 'less') {
return [${themeFolder}/src/${partialName}.less
]
} else if (importStyle === true || importStyle === 'css') {
return [${themeFolder}/bc-${partialName}.css
]
}
}
function kebabCase(key) {
const result = key.replace(/([A-Z])/g, ' $1').trim()
return result.split(' ').join('-').toLowerCase()
}
function resolveComponent(name, options) {
if (options.exclude && name.match(options.exclude)) return
if (!name.match(/^Bc[A-Z]/)) return
const partialName = kebabCase(name.slice(2)) // ElTableColumn -> table-column
return {
name: name.slice(2),
from: bc-element/es
,
sideEffects: getSideEffectsLegacy(partialName, options),
}
}
const noStylesComponents = []
function BcElementResolver(options) { let optionsResolved
async function resolveOptions() { if (optionsResolved) return optionsResolved optionsResolved = { importStyle: 'css', exclude: undefined, noStylesComponents: (options && options.noStylesComponents) || [], ...options, } return optionsResolved }
return [ { type: 'component', resolve: async name => { const options = await resolveOptions()
if ([...options.noStylesComponents, ...noStylesComponents].includes(name))
return resolveComponent(name, { ...options, importStyle: false })
else return resolveComponent(name, options)
},
},
] } module.exports = BcElementResolver
删除 node_modules 重新安装
Describe the bug
"unplugin-auto-import": "^0.16.4", "unplugin-element-plus": "^0.7.1", "unplugin-vue-components": "^0.25.1", 自定义组件库 使用按需引入 使用最新版本 dev之后 报错 :Module parse failed: 'import' and 'export' may only appear at the top level (115:0) 使用 unplugin-vue-components:'^0.18.4' 版本没问题
Reproduction
ElementResolver 使用的是 ElementPlusResolver 自定义组件库是基于element-plus
System Info
Used Package Manager
npm
Validations