Esbuild: React Fast Refresh

Created on 26 May 2020  路  3Comments  路  Source: evanw/esbuild

Since React Fast Refresh requires bundler specific work, I am creating this issue just to track this work. It's not high priority at all.

You mentioned you are planning for plugins in future. This would be a good candidate to test your plugin API design.

Here is a rough document for how to implement React Fast Refresh.

Most helpful comment

I'm not sure this makes sense as part of esbuild. First of all esbuild is focused on production builds, not development builds. I am also trying to avoid building in complicated custom transforms for various frameworks like this. For example, I'm not planning to replicate the compiler pipelines of Vue, Svelte, or Angular either. That's why the readme says "I'm not trying to create an extremely flexible build system that can build anything."

In a world where esbuild has support for JavaScript plugins, it could potentially make sense to add this as a plugin. Or it could make sense to use esbuild's transform API to speed up another bundler that has React Fast Refresh support, and for people who want to use React Fast Refresh with esbuild to use that bundler instead.

All 3 comments

I guess this could be solved with this one https://github.com/evanw/esbuild/issues/111 but it's more complex than that.
I think it would be good to have feature pairty with create react app. For now esbuild lacks svg import feature to be compat with cra.

As for reach refresh it requires more more work than plugins system, we would also need some api for hot updates so it might require this feature https://github.com/evanw/esbuild/issues/21 to be finished as well.

I'm not sure this makes sense as part of esbuild. First of all esbuild is focused on production builds, not development builds. I am also trying to avoid building in complicated custom transforms for various frameworks like this. For example, I'm not planning to replicate the compiler pipelines of Vue, Svelte, or Angular either. That's why the readme says "I'm not trying to create an extremely flexible build system that can build anything."

In a world where esbuild has support for JavaScript plugins, it could potentially make sense to add this as a plugin. Or it could make sense to use esbuild's transform API to speed up another bundler that has React Fast Refresh support, and for people who want to use React Fast Refresh with esbuild to use that bundler instead.

I'm going to close this because I believe the above answer is sufficient for this issue. It's true that someone could possibly write an esbuild plugin for this in the future, but I'm not going to keep issues open for each potential esbuild plugin. There are too many of them and it's not useful for me to track them in separate issues. This issue has already been linked to #111, the general issue for the plugin API, so it won't be lost.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

OneOfOne picture OneOfOne  路  3Comments

aelbore picture aelbore  路  4Comments

qnp picture qnp  路  4Comments

aelbore picture aelbore  路  3Comments

egoist picture egoist  路  3Comments