developit / developit/htm

Optimize adjacent static parts+fields

未关闭
#90 0 条评论 5 个 reaction 已指派 0 人 在 GitHub 查看
enhancement proposal
主要语言
JavaScript
星标
9k
派生
181
PR 合并指标
30 天内没有已合并 PR

描述

I've been [toying around with optimizing Tagged Templates](https://gist.github.com/developit/7118c02bf0270e1d5751d2a9e22c1faa) by merging literal field values (strings, numbers and booleans) into their adjacent static part and collapsing the adjacent static parts into a single part:

```js
// input:

hello

// current output:
html`

hello
`
html ``

// optimized output:
html`

`
html`
`
```

It'd be really neat to get this behavior into `babel-plugin-transform-jsx-to-htm`, since additional assumptions could be made about nested Arrays:

```js
const color = 'red';

// input:
{`
.foo { color: ${color}; }
`}

// current output:
html`
${`
.foo { color: ${color}; }
`}
`

// optimized output:
html`

.foo { color: ${color}; }

`
```

Thoughts?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。