microsoft / fast

The adaptive interface system for modern web experiences.
https://www.fast.design
Other
9.25k stars 591 forks source link

feat: provide `html.partial` and `css.partial` as standalone tagged template literals #6961

Open radium-v opened 4 months ago

radium-v commented 4 months ago

🙋 Feature Request

It would be very convenient to provide the html.partial() and css.partial methods as tagged template literal functions. Perhaps both the methods and the tagged template literal functions could coexist:

// Since `css.partial` is already a TTL, it can be reflected
export const cssPartial = css.partial;

// `html.partial` only accepts one string so it has to be transformed
export const htmlPartial = (strings: TemplateStringsArray, ...values: any[]) => html.partial(strings[0]);

🔦 Context

The css.partial and html.partial() methods can't be compressed at build-time with most tagged template literal optimization methods, which usually work by identifying a tagged template literal via an AST. Our current solution is a rollup plugin which accepts an array of tags to optimize, but the AST implementation only sees partial and not the full css.partial or html.partial.