denoland / deno_ast

Source text parsing, lexing, and AST related functionality for Deno
https://crates.io/crates/deno_ast
MIT License
144 stars 43 forks source link

feat: option to force dynamic jsx precompile props #259

Closed marvinhagemeister closed 1 month ago

marvinhagemeister commented 1 month ago

There are scenarios where framework plugins want to be able to intercept creation of properties. Some Fresh plugins like the current unocss and twind plugin want to intercept all class/className props to render CSS. All other properties not in the list should be treated as usual.

const a = <div class="foo" />

// Before: Not interceptible
const tpl = [
  '<div class="foo"></div>'
]
const a = jsxTemplate(tpl)

// After: interceptible if prop is excluded
const tpl = [
  "<div ",
  "></div>"
]
const a = jsxTemplate(tpl, jsxAttr("class", "foo"))

Related https://github.com/denoland/fresh/issues/2540