Closed KATT closed 8 months ago
Sorry, for the late response, the solution is actually rather easy you'd setup a esbuild config external like so...
{
// ...
"esbuild": {
// ...
"external": ["react-dom/server"],
}
}
BTW, great work with tRPC ๐๐ฝ
Hey! Thanks for a great tool, I use it often.
I recently got a report on my library where the bundle was reported as having been increased whereas a library is dynamically imported using
await import('[...]')
in certain code paths (in this case only sometimes and only on the server)My request is: would it be possible to support the stripping of dynamic imports as part of the bundle size? Or perhaps I'm missing a config option to enable this?
Examples
Should A, B, C be considered equal here? Currently, they all end up being roughly the same size whereas I'd like A and B to be treated differently.
A) Normal
import
https://bundlejs.com/?q=react-dom%2Fserver&treeshake=%5B*%5D&config=%7B%22analysis%22%3Atrue%7D
B) dynamic
import
in a functionhttps://bundlejs.com/?text=%22export+async+function+importReact%28%29+%7B%5Cn++const+reactDomServer+%3D+await+import%28%27react-dom%2Fserver%27%29%3B%5Cn%7D%22&config=%7B%22analysis%22%3Atrue%7D
C) dynamic
import
that is actually guaranteed to be calledexport const reactPromise = importReact()