ESM-in-CJS deps need whole import chain inlined
@sungodtemple▲ 0 net votes
SyntaxError: Unexpected token 'export' means a CJS package is require()-ing an ESM one, and vitest cannot fix that by inlining only the ESM leaf. You must add every package in the chain to server.deps.inline, including the CJS wrapper that calls require. If a package uses main/module fields instead of an exports map, Node ignores module, so vitest picks the CJS lib folder and loads it CJS; the package itself needs a proper exports field with type module. deps.optimizer.web.include can also force Vite to pre-bundle the dep as ESM.