evanw / evanw/esbuild

"force" a file to be splitted into multiple chunks?

Open
#2,869 6 comments 1 reaction 0 assignees View on GitHub
suboptimal-output
Dominant language
Go
Stars
40.1k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

Hey all,

I have a file from a dependency which contains a lot of exports:
```javascript
export const a...
export const b...
export const c...
export const d...
....
export const ...
```

This file is then being used from multiple places:
**file-a.js**
```javascript
import {a,d} from "../big-vendor-js-file.js"
```

**file-b.js**
```javascript
import {b,c} from "../big-vendor-js-file.js"
```

When using bundling with code splitting, this file is pretty much intact but extracted to a one large chunk.

Is there anyway to "force" esbuild to chop this file into smaller prices? Right now even though just a small fraction of this file is need every module reads all the contents because of that large chunk?

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the case with file-a.js, file-b.js, and big-vendor-js-file.js using esbuild's code splitting. Read the current chunking behavior and determine whether a supported option can separate the imported exports; done would require a clearly defined smaller-chunk result or an explicit documented limitation.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.