packup icon indicating copy to clipboard operation
packup copied to clipboard

feat: Leverage esbuild CLI commands

Open Leokuma opened this issue 6 months ago • 1 comments

Thank you for this very underrated project.

Is your feature request related to a problem? Please describe The main motivation for this issue is the same as #45, but I have more points to bring to the table.

I use the bundled version of Lit. I import that file in every Lit component I have, and packup build ends up adding the entire Lit bundle to every component.

Describe the solution you'd like I'd like Packup to have an option to just transpile TS, without bundling. That would solve the problem for me.

Describe alternatives you've considered Since esbuild supports transpiling without bundling, could Packup leverage esbuild commands? I was wondering if Packup could just forward to esbuild whatever commands Packup receives via CLI.

By doing that, we would automatically give the user the option to minify, mangle, add a footer, limit line length, tweak path resolution and everything else that esbuilds supports. Whenever esbuild adds a new feature, it could be easily added to Packup as well, and the docs would always be up to date because the user could refer to esbuild's docs.

So packup build would be become packup build --bundle (because esbuild takes the --bundle arg). And immediately we would support esbuild flags like --minify, --keep-names, --mangle-props, --minify-whitespace and others. Same thing for packup serve.

Caveats

  • I guess not all esbuild flags will work OOTB (e.g. code splitting). We could intercept those flags and inform the user that they are not supported yet.
  • Packup's own CLI args would be mixed with esbuild's args, which means they probably shouldn't have the same names. We could prefix Packup's args to avoid naming collisions with esbuild.

Let me know if you like the idea 👍.

Leokuma avatar Aug 20 '24 20:08 Leokuma