evanw / evanw/esbuild

Question: Externals in a specific folder but tree shaked

Open
#3,597 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

_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.

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue names no files or tests. Start by reading the follow-up in #3563 and tracing how esbuild handles multiple entry points, external modules, and tree shaking; done would mean defining a supported way to place externals in a separate folder without losing the exports needed by each entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.