evanw / evanw/esbuild

Question: Manually importing chunks server-side

Open
#3,950 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

Sorry, this is a question, not a bug.

I am migrating an app from Webpack and I am using the `webpackChunkName` feature, which is not currently supported by esbuild. I am determined to make this work though because the improvement to my workflow is so enormous (thanks!).

esbuild is currently creating chunks that are not exactly aligned with what I want, because of the aforementioned lack of `webpackChunkName` support. To get around this, I am hoping to manually concatenate the relevant chunks server-side.

I will need to manually parse through the main chunk to find the chunk IDs (I can do this), but I am struggling with how to make the exports/imports work.

The chunks have this at the bottom:

```
export{fa as a,Kf as b,Jf as c,G2 as d,$1 as e,PC as f, [...]
```

and the main chunk has this:

```
import{Oa as ie,Sa as he,Ta as we, [...]} from"/[...]/chunk.TJ4BB7AT.js";
```

Question is: what modifications do I need to do so that I can manually put the split chunks at the top of the main chunk?

Thanks!

Contributor guide

No contributing guide indexed for this repository

Research direction

No source file, test, or entry point is named. Start by reviewing the generated main chunk and split chunks shown in the report, then determine whether the requested webpackChunkName behavior or server-side concatenation is supported. Done would require a documented, supported way to achieve the requested chunk layout.

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.