# 2024년 6월 12일 작업일지

### SWC 파서 최적화

* [https://github.com/swc-project/swc/pull/9037](https://github.com/swc-project/swc/pull/9037)
    

어제 했던 작업이랑 거의 비슷한 작업이다.

### SWC Minifier 성능 Regression 수정

* [https://github.com/swc-project/swc/pull/9039](https://github.com/swc-project/swc/pull/9039)
    

어제 한 작업이 지나치게 간단한 해결 방법을 써서 시간 복잡도가 `O(n^2)`가 됐다. 그걸 고치는 PR이다.

### SWC CI Regression 수정

* [https://github.com/swc-project/swc/pull/9040](https://github.com/swc-project/swc/pull/9040)
    

CI가 CLI 바이너리 파일을 GitHub Releases에 올리지 않는 문제가 있어서 한 작업이다.

### `swc_core` 업데이트

* [https://github.com/vercel/turbo/pull/8447](https://github.com/vercel/turbo/pull/8447)
    
* [https://github.com/vercel/next.js/pull/66781](https://github.com/vercel/next.js/pull/66781)
    

파서 성능 개선 PR들을 빨리 적용할 필요성이 있어서 빠르게 업데이트 PR 만들었다.

### 터보팩 Tree Shaking 최적화

* [https://github.com/vercel/turbo/pull/8420](https://github.com/vercel/turbo/pull/8420)
    
* `x = 2`의 의존성 (`deps`)에 `x` 선언이 없음.
    

```plaintext
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:248:13] ix = 4
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:263:13] &required_vars = {
    (
        "x",
        #2,
    ),
}
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:266:17] id = ItemId(1, Normal)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:350:25] "Exporting" = "Exporting"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:350:25] var = (
    "x",
    #2,
)
```

`x = 3`의 로그는 아래와 같다.

```plaintext
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:248:13] ix = 5
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:263:13] &required_vars = {
    (
        "x",
        #2,
    ),
}
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:266:17] id = ItemId(2, Normal)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:350:25] "Exporting" = "Exporting"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:350:25] var = (
    "x",
    #2,
)
```

마찬가지로 `var_decl`에 대한 의존성이 없다. last read에만 의존성을 추가해서 그런 것 같다.

* `x +=6`의 의존성에 `last_write`만 있어야하는데 이전의 모든 write가 있음.
    

```plaintext
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:248:13] ix = 8
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:263:13] &required_vars = {
    (
        "x",
        #2,
    ),
}
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:266:17] id = ItemId(5, Normal)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:297:17] dep = 3
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:307:29] "Importing" = "Importing"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:307:29] var = (
    "x",
    #2,
)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] "Skipping" = "Skipping"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] var = (
    "x",
    #2,
)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:297:17] dep = 4
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] "Skipping" = "Skipping"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] var = (
    "x",
    #2,
)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:297:17] dep = 5
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] "Skipping" = "Skipping"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] var = (
    "x",
    #2,
)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:297:17] dep = 6
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] "Skipping" = "Skipping"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] var = (
    "x",
    #2,
)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:297:17] dep = 7
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] "Skipping" = "Skipping"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:315:29] var = (
    "x",
    #2,
)
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:349:25] "Exporting" = "Exporting"
[crates/turbopack-ecmascript/src/tree_shake/graph.rs:349:25] var = (
    "x",
    #2,
)
```

* 변수를 선언하지 않는 모듈이 변수를 export 함
    

어찌어찌 조금씩 진행했다.

### SWC: `no-dupe-args` 린트 최적화

* [https://github.com/swc-project/swc/pull/9041](https://github.com/swc-project/swc/pull/9041)
    

린트 패스지만 메모리 할당이 프로파일링 결과에서 눈에 띌 정도였어서 에러가 없는 경우 아예 메모리 할당을 하지 않게 패치했다.

### SWC: `xtask npm nightly` 버그 수정

* [https://github.com/swc-project/swc/pull/9042](https://github.com/swc-project/swc/pull/9042)
    

SWC 나이틀리가 제대로 배포가 안 되길래 수정했다.
