developit / developit/htm

Optimize adjacent static parts+fields

Đang mở
#90 0 bình luận 5 reaction 0 người được giao Xem trên GitHub
enhancement proposal
Ngôn ngữ chính
JavaScript
Star
9k
Fork
181
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.