Skip to content

Commit

Permalink
fix: 修复自定义组件taro无样式问题
Browse files Browse the repository at this point in the history
  • Loading branch information
heiazu committed May 9, 2024
1 parent b7a7990 commit 423b642
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 3 deletions.
64 changes: 61 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,72 @@ switch (platform) {
}
break
case 'arm':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'parse-css-to-stylesheet.linux-arm-musleabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parse-css-to-stylesheet.linux-arm-musleabihf.node')
} else {
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-musleabihf')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'parse-css-to-stylesheet.linux-arm-gnueabihf.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parse-css-to-stylesheet.linux-arm-gnueabihf.node')
} else {
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf')
}
} catch (e) {
loadError = e
}
}
break
case 'riscv64':
if (isMusl()) {
localFileExisted = existsSync(
join(__dirname, 'parse-css-to-stylesheet.linux-riscv64-musl.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parse-css-to-stylesheet.linux-riscv64-musl.node')
} else {
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-riscv64-musl')
}
} catch (e) {
loadError = e
}
} else {
localFileExisted = existsSync(
join(__dirname, 'parse-css-to-stylesheet.linux-riscv64-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parse-css-to-stylesheet.linux-riscv64-gnu.node')
} else {
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-riscv64-gnu')
}
} catch (e) {
loadError = e
}
}
break
case 's390x':
localFileExisted = existsSync(
join(__dirname, 'parse-css-to-stylesheet.linux-arm-gnueabihf.node')
join(__dirname, 'parse-css-to-stylesheet.linux-s390x-gnu.node')
)
try {
if (localFileExisted) {
nativeBinding = require('./parse-css-to-stylesheet.linux-arm-gnueabihf.node')
nativeBinding = require('./parse-css-to-stylesheet.linux-s390x-gnu.node')
} else {
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-arm-gnueabihf')
nativeBinding = require('@tarojs/parse-css-to-stylesheet-linux-s390x-gnu')
}
} catch (e) {
loadError = e
Expand Down
15 changes: 15 additions & 0 deletions src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,13 @@ impl VisitMut for ObjectFinder {
],
})),
}))
));
props.insert(
0,
PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
key: PropName::Ident(Ident::new("__hmStyle".into(), DUMMY_SP)),
value: Box::new(ObjectFinder::get_fun_call_expr(class_attr_value.clone())),
}))
))
}
}
Expand Down Expand Up @@ -1457,6 +1464,14 @@ impl<'i> VisitMut for JSXMutVisitor<'i> {
}))),
})),
}));
n.opening.attrs.push(JSXAttrOrSpread::JSXAttr(JSXAttr {
span: DUMMY_SP,
name: JSXAttrName::Ident(Ident::new("__hmStyle".into(), DUMMY_SP)),
value: Some(JSXAttrValue::JSXExprContainer(JSXExprContainer {
span: DUMMY_SP,
expr: JSXExpr::Expr(Box::new(get_fun_call_expr(class_attr_value.clone()))),
})),
}));
},
None => {},
}
Expand Down

0 comments on commit 423b642

Please # to comment.