then()という名前の関数をexportしない
from import()
moduleからthen()という名前の関数をexportすると、
static importか
dynamic importか
で挙動が異なる
import()を使ってdynamic importされた場合、Thenable Objectだとみなされる
Warning: Do not export a function called then() from a module. This will cause the module to behave differently when imported dynamically than when imported statically.
then() を export した結果www - Object.create(null)
Vitestは、hoistMocksPluginを使って、全てのstatic importをdynamic importに変換する
そのため、then()という関数をexportしてるとVitestがhangする
Vitest gets stuck during build of actor 3rd party library (named export then ) · Issue #5122 · vitest-dev/vitest · GitHub
最小のサンプル
https://github.com/mrsekut/vitest-then-hang.git