Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild doesn't remove unused imports from external modules #1794

Open
egoist opened this issue Nov 22, 2021 · 10 comments
Open

esbuild doesn't remove unused imports from external modules #1794

egoist opened this issue Nov 22, 2021 · 10 comments

Comments

@egoist
Copy link

egoist commented Nov 22, 2021

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 egoist changed the title esbuild doesn't unused imports from external modules esbuild doesn't remove unused imports from external modules Nov 22, 2021
@cyan-2048
Copy link

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
Copy link

darn it! i was going to move to esbuild

@hanayashiki
Copy link

any updates on this?

@cyan-2048
Copy link

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

@ghost
Copy link

ghost commented Mar 13, 2023

Any updates on this? Maybe a plugin could help?

@shixish
Copy link

shixish commented Sep 21, 2023

Darn I'm seeing this as well...

@jagribble
Copy link

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

@sofienjoulak
Copy link

hopefully one day....

@jhaemin
Copy link

jhaemin commented Feb 21, 2024

Any updates? esbuild bundles everything

@alexmorleyfinch
Copy link

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants