ncc icon indicating copy to clipboard operation
ncc copied to clipboard

ncc build generating multiple index.js files instead of a single bundle after upgrading Node.js

Open sureshrucko opened this issue 4 months ago • 2 comments

After updating my Node.js version to v22.18.0, I’ve noticed that running NCC (@vercel/ncc) version 0.38.3 now produces multiple index.js files in the output directory instead of a single bundled file as it did before.

Previously, the same command produced only one index.js file.

Node.js version: v22.18.0

@vercel/ncc version: 0.38.3

os: windows

Command used: npx ncc build src/main.ts -o dist

Output:

3kB  dist\906.index.js
5kB  dist\218.index.js
9kB  dist\135.index.js
9kB  dist\949.index.js
11kB  dist\215.index.js
15kB  dist\164.index.js
39kB  dist\953.index.js
54kB  dist\270.index.js
63kB  dist\840.index.js
26989kB  dist\index.js

The same build on older Node.js versions (e.g., 20.x) produced a single file as expected.

sureshrucko avatar Oct 13 '25 06:10 sureshrucko

I thought I had the same problem, but I realized this was actually caused by an update of a dependency. The dependency (aws sdk In my case) introduced some code which does await import(...) at runtime and this conditional import then ended up in an *.index.js. It is possible you have the same thing?

I was looking how the numbered index file are used in the main index.js (e.g. I searched for 953 in dist/index.js) and the try to understand where this comes from.

stschulte avatar Nov 19 '25 22:11 stschulte

@stschulte Thanks for your message! Yes, correct — the issue was caused by an update in the dependencies @aws-sdk/client-s3 (^3.620.0) and @aws-sdk/s3-request-presigner (^3.620.0). For debugging purposes, I removed the ^ from their version numbers, and after that the build started generating a single index file again.

sureshrucko avatar Nov 20 '25 08:11 sureshrucko