Next.js Discord

Discord Forum

Build failed, seemingly from re-exports from index files

Answered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
  ▲ Next.js 14.2.4
  - Environments: .env

   Creating an optimized production build ...
Failed to compile.

./src/lib/infrastructure/services/AIService/index.tsx + 22 modules
Cannot get final name for export 'format' of __barrel_optimize__?names=format,formatDistanceToNow!=!./node_modules/.pnpm/date-fns@3.6.0/node_modules/date-fns/index.mjs


I can chip away at these errors in 22 modules by changing my imports like this:

import {format} from "data-fns ===> import {format} from "date-fns/format"

It is also complaining about re-exporting from index files in src/. I did manually downgrade from 15rc.0 to 14.2.4, so maybe there's some config i missed.


https://github.com/john-prutton/carley
Answered by Thrianta
After correcting the errors one by one, this builds. Here are the changes I had to make.

https://github.com/john-prutton/carley/commit/04f70b03cc2a7a2f05c3809976daaf7dccd248ec
View full answer

5 Replies

ThriantaOP
After correcting the errors one by one, this builds. Here are the changes I had to make.

https://github.com/john-prutton/carley/commit/04f70b03cc2a7a2f05c3809976daaf7dccd248ec
Answer
ThriantaOP
Im still confused about why I had to change imports for LoadingBubble and MessageBubble. I get date-fns treeshaking reasons, but i dont date-fns in those components. @/joulev , do you maybe have an idea?
I don’t use barrel imports myself so I haven’t looked into whether it is indeed a bug and how to properly fix it
ThriantaOP
Cool np. Is this something I should report? Any idea on how to create a min-repro repo? Considering they look like normal components.