esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Question: Externals in a specific folder but tree shaked

Open Alex134831 opened this issue 1 year ago • 0 comments

Wish we had an official Discord server or at least the Discussions section.

This is a follow up to #3563

I'm trying to make esbuild put externals separately in a specific folder. But it removes tree shaking since the main files aren't entry points.

Also I'm using multiple entry points with outdir because it is for a multi page website. Normally an entry point that uses a lib would tree shake the lib, but put the code inside the out file. I need to separate the externals, but at the same time, let it know which exports are used.

Does anyone have an idea to solve this? I thought about collecting imported names of each file and making a JS file that just imports those names so bundling the file would give the tree shaked lib, but esbuild doesn't let us know those names if I'm not mistaken.

What I currently have is just external modules as entryPoints.

Alex134831 avatar Jan 16 '24 13:01 Alex134831