esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

esbuild doesn't remove unused imports from external modules

Open egoist opened this issue 3 years ago • 11 comments

Tested against:

export { useRoute } from "vue-router"

The command I ran:

esbuild index.js --bundle --outfile=out.js --external:vue --format=esm

Result, unused imports from vue:

CleanShot 2021-11-22 at 21 33 08@2x

Online playground:

https://stackblitz.com/edit/node-fm1edb?file=readme.md

egoist avatar Nov 22 '21 13:11 egoist

same problem here...

// helper.js
import scrollIntoView from "scroll-into-view";

export async function centerScroll(){
return scrollIntoView(/* ... */)
}

export async function delay(){
// ...
}
import {delay} from "./helper.js"
/* this causes scrollIntoView to also be in the bundle!  */

cyan-2048 avatar Jul 12 '22 07:07 cyan-2048

darn it! i was going to move to esbuild

cyan-2048 avatar Jul 12 '22 07:07 cyan-2048

any updates on this?

hanayashiki avatar Aug 30 '22 12:08 hanayashiki

i wish this could be fixed, esbuild is literally perfect.... except this problem, one of the reasons to use a bundler is because of the tree shaking

cyan-2048 avatar Aug 30 '22 23:08 cyan-2048

Any updates on this? Maybe a plugin could help?

ghost avatar Mar 13 '23 17:03 ghost

Darn I'm seeing this as well...

shixish avatar Sep 21 '23 01:09 shixish

Thought I was going mad. Also seeing this when using named imports

jagribble avatar Dec 08 '23 09:12 jagribble

hopefully one day....

sofienjoulak avatar Jan 09 '24 17:01 sofienjoulak

Any updates? esbuild bundles everything

jhaemin avatar Feb 21 '24 14:02 jhaemin