evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
38.21k stars 1.15k forks source link

Question: Manually importing chunks server-side #3950

Open mattparlane opened 4 weeks ago

mattparlane commented 4 weeks ago

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!