Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild導入検討 #27

Closed
qrac opened this issue Jan 23, 2022 · 3 comments
Closed

esbuild導入検討 #27

qrac opened this issue Jan 23, 2022 · 3 comments

Comments

@qrac
Copy link
Owner

qrac commented Jan 23, 2022

Viteなどに比べるとwebpackの遅さが気になるので、なるべく高速化したい。

esbuild-loaderをbabel-loader + ts-loaderの場合と比較したところ、3〜4割ほど速くなった。
※別件でswc-loaderを検証したときはと1割高速化

image

仕組み上、爆速とまではいかなかったが導入してみたい。そのまま差し替えるとbabel-loader + ts-loaderを使っているプロジェクトとの互換性問題や新たな不具合が心配なので、CLIオプションで使用できると良いかもしれない。

@qrac
Copy link
Owner Author

qrac commented Jan 26, 2022

esbuild-loaderはReactの自動インポートに対応していないため、ProvidePluginで挿入する必要がある。

const { ProvidePlugin } = require('webpack')

const webpackConfig = {
  plugins: [
    new webpack.ProvidePlugin({
      React: "react"
    })
  ]
}

module.exports = webpackConfig

@qrac
Copy link
Owner Author

qrac commented Jan 26, 2022

esbuildには公式のコンフィグファイルがないので、設定のオーバーライドについて考える必要がある。

暫定的に非公式の esbuild.config.json でオーバーライドしてもらうことにして、もし公式のjsonファイルが登場したらどちらもサポートするという方法は取れる。

esbuildを使う場合は、条件分岐でbabel-loader + ts-loaderの設定をオフにしないとならない。派生プラグインを作って、それがインストールされている場合は 切り替えるなどの方法が考えられる。

@qrac
Copy link
Owner Author

qrac commented Jan 26, 2022

現在の制作でビルド速度がそこまでボトルネックになっていないため保留とする。速度を重視するのであれば、Viteなどの爆速バンドラーベースの新構成に時間を割いた方が良いと考える。

@qrac qrac closed this as completed Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant