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?

貢獻指南

開啟貢獻指南

研究方向

從連結的 Tagged Templates gist 和 babel-plugin-transform-jsx-to-htm 進入點開始。比較針對字面值欄位和巢狀陣列所顯示的目前輸出與最佳化後輸出;當 plugin 為兩個範例都產生所要求的最佳化後輸出時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
babel, javascript
領域
compilers, tooling
Issue 類型
功能
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。