UNPKG

nutui-taro-upgrade

Version:

@nutui/nutui-taro 对京东风格组件库的taro4 版本支持

28 lines (27 loc) 851 B
const nutFunctions = ["showToast", "showNotify", "showDialog", "showImagePreview"]; function getNutResolved(name, options) { const { taro = false, autoImport = false } = options; const packageName = taro ? "nutui-taro-upgrade" : "@nutui/nutui"; const componentName = autoImport ? name.slice(4) : name; const style = `${packageName}/dist/packages/${componentName.toLowerCase()}/style`; return { name, from: packageName, sideEffects: style }; } function NutUIResolver(options = {}) { return { type: "component", resolve: (name) => { const { autoImport = false } = options; if (autoImport && nutFunctions.includes(name)) return getNutResolved(name, options); if (name.startsWith("Nut")) return getNutResolved(name.slice(3), options); } }; } export { NutUIResolver as default };