The Next.js build system was too aggressive in its tree shaking and removed mime-types from the bundle (required by form-data which is required by @literalai/client).
It was the dumbest thing as mime-types was declared as a dep despite not being imported anywhere in the code, while form-data was imported in the code but not declared as a dep. This didn't trigger any compile error as it is mainlined in Node (and presumed to exist by tsc/swc) but the build process messed the whole dependency graph and the error appeared at runtime.
The Next.js build system was too aggressive in its tree shaking and removed
mime-types
from the bundle (required byform-data
which is required by@literalai/client
).It was the dumbest thing as
mime-types
was declared as a dep despite not being imported anywhere in the code, whileform-data
was imported in the code but not declared as a dep. This didn't trigger any compile error as it is mainlined in Node (and presumed to exist by tsc/swc) but the build process messed the whole dependency graph and the error appeared at runtime.