preact-compat
preact-compat copied to clipboard
Mistake in main docs? Need to remove transform-react-jsx?
Hello, started setuping a build process with babel and module-resolver, but it get working only when I remove transform-react-jsx plugin. When it included I got an error that function h is not exists. Maybe you need to remove that plugin from docs, but I can be wrong.
Thanks for preact-compat.
{
// ...
"plugins": [
["transform-react-jsx", { "pragma":"h" }],
["module-resolver", {
"root": ["."],
"alias": {
"react": "preact-compat",
"react-dom": "preact-compat"
}
}]
],
"presets": [
"react"
]
// ...
}
Hi @jmas - I think the docs for this must be slightly confusing, we've had a few people end up with that issue. The custom pragma option is actually only for those using preact without preact-compat. If you're wanting to use preact-compat (and refer to things as React in your codebase), you don't need any options at all - the "react" preset is fine.
{
// ...
"plugins": [
["module-resolver", {
"root": ["."],
"alias": {
"react": "preact-compat",
"react-dom": "preact-compat"
}
}]
],
"presets": [
"react"
]
// ...
}
Alternatively, you can skip the react preset and just add the JSX plugin:
{
// ...
"plugins": [
["transform-react-jsx"],
["module-resolver", {
"root": ["."],
"alias": {
"react": "preact-compat",
"react-dom": "preact-compat"
}
}]
],
"presets": []
// ...
}
By the way, if you add me as a contributor on babel-preset-preact I'd be happy to publish a working version! ❤️