gregberge / loadable-components

The recommended Code Splitting library for React ✂️✨
https://loadable-components.com
MIT License
7.58k stars 376 forks source link

Add esbuild support #995

Closed Skyler-Wu closed 5 months ago

Skyler-Wu commented 5 months ago

💬 Questions and Help

Hi guys, I noticed in the few past years you don't have plan to add esbuild support, in this issue, now just wanna double check that you still have no plans for esbuild support, right?

theKashey commented 5 months ago

No plans yet.

But the "integration" is only around getting required stats from the build, so we can connect the dots. Basically create an analog of webpack-plugin for esbuild/vite/you-name-it and keep the rest.

Skyler-Wu commented 5 months ago

Thanks first, and if I wanna use esbuild-loader + webpack + loadable, without @loadable/babel-plugin, you have some suggestions?

theKashey commented 5 months ago

Sorry, it would not work. Babel is the most crucial part of instrumentation and should still happen. As a solution you can create a custom loader that will quickly scan source file and pick the right loader to use:

Just a few files of the whole project require extra functionality from babel-plugin, while all others do not. By mixing loaders you can combine speed of esbuild with power of babel.

There is a separate solution a little easier to implement - create a "conditional loader" and place it before esbuild: