# 2024년 6월 10일 작업일지

### mdxjs-rs의 `swc_core` 업데이트

* [https://github.com/wooorm/mdxjs-rs/pull/46](https://github.com/wooorm/mdxjs-rs/pull/46)
    

next.js와 turbopack의 `swc_core`를 업데이트하려면 이 작업이 필요하다. 메인테이너분께서 빠르게 머지해주셔서 저녁 때엔 next.js/turbopack용 PR을 만들 수 있었다.

### SWC Renamer: 사파리 버그

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

SWC의 버그는 아니지만 workaround가 가능한 종류라 간단하게 고쳤다.

### next.js: 터보팩 Tree shaking 활성화

* [https://github.com/vercel/next.js/pull/66689](https://github.com/vercel/next.js/pull/66689)
    

Tree shaking 구현체를 next.js를 이용해서 테스트하는 게 주 목적이다.

### `swc_core` Regression

next.js의 `swc_core` 를 `v0.92.5`에서 `v0.92.10` 로 업데이트했더니 문제가 발생했다.

* 커밋 범위: [4fc3c66...8bb302a](https://github.com/swc-project/swc/compare/4fc3c66f8f471687b609773e4b9d8494e6b91489...8bb302a508c7ab7c595349c15c6c61a9cb87adcc)
    

프로덕션 코드에 영향을 끼칠 수 없는 PR을 제외하면,

* [https://github.com/swc-project/swc/pull/8965](https://github.com/swc-project/swc/pull/8965)
    
* [https://github.com/swc-project/swc/pull/8973](https://github.com/swc-project/swc/pull/8973)
    
* [https://github.com/swc-project/swc/pull/8975](https://github.com/swc-project/swc/pull/8975)
    
* [https://github.com/swc-project/swc/pull/8976](https://github.com/swc-project/swc/pull/8976)
    
* [https://github.com/swc-project/swc/pull/8986](https://github.com/swc-project/swc/pull/8986)
    
* [https://github.com/swc-project/swc/pull/8993](https://github.com/swc-project/swc/pull/8993)
    
* [https://github.com/swc-project/swc/pull/9005](https://github.com/swc-project/swc/pull/9005)
    
* [https://github.com/swc-project/swc/pull/8987](https://github.com/swc-project/swc/pull/8987)
    
* [https://github.com/swc-project/swc/pull/9012](https://github.com/swc-project/swc/pull/9012)
    
* [https://github.com/swc-project/swc/pull/9013](https://github.com/swc-project/swc/pull/9013)
    
* [https://github.com/swc-project/swc/pull/9011](https://github.com/swc-project/swc/pull/9011)
    

이 PR들이 남는다.

### 터보팩 Scope Hoisting PR

* [https://github.com/vercel/turbo/pull/8271](https://github.com/vercel/turbo/pull/8271)
    

테스트 스냅샷 업데이트했다.

### `@swc/core` @ `v1.5.27` 배포

* [커밋](https://github.com/swc-project/swc/commit/3f7820a3a15396b6b8ad02ab1fcb3844de4fa419)
    

### 터보팩 Tree Shaking 개선

* [https://github.com/vercel/turbo/pull/8370](https://github.com/vercel/turbo/pull/8370)
    

여러가지 시도를 하다가,

```rust
     fn visit_ident(&mut self, n: &Ident) {
        if n.sym == *"order" {
            self.vars.read.insert(n.to_id());
            self.vars.write.insert(n.to_id());
        }

        // We allow SyntaxContext::empty() because Some built-in files do not go into
        // resolver()
        if !self.only.contains(&n.span.ctxt) && n.span.ctxt != SyntaxContext::empty() {
            return;
        }

        match self.mode {
            Mode::Read => {
                self.vars.read.insert(n.to_id());
            }
            Mode::Write => {
                self.vars.write.insert(n.to_id());
            }
        }
    }
```

처럼 `order` 라는 이름의 변수만 특수 처리를 해서 테스트가 통과하는 것을 확인했다. 이것이 작동한다는 것은 올바른 규칙에 의해 `order`이 READ + WRITE로 표시되면 문제가 해결된다는 것을 의미한다. 그래서 비지터 코드를 적당히 수정했고, 문제가 해결됐다.

### `swc_core` @ `v0.93.x`업데이트

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

`swc_core` regression 디버깅을 하려면 `swc_core`의 버전을 업데이트한 뒤에 `cargo` 의 patch 기능을 이용해서 로컬 복제본을 가리키게 해야하는데, `swc_core`의 버전을 업데이트 한 김에 PR들은 만들어놨다.
