fix(vite): empty commonjs files with only __esModule (#3540)

When modules only contain the `__esModule` flag, we still need to add
the `exports` and `module.exports` initializers.
This commit is contained in:
Marvin Hagemeister
2025-10-08 11:50:34 +02:00
committed by GitHub
parent 6c03a9bc26
commit 4b069ee0d0
2 changed files with 9 additions and 5 deletions
@@ -134,7 +134,7 @@ export function cjsPlugin(
);
}
if (exported.size > 0 || exportedNs.size > 0) {
if (exported.size > 0 || exportedNs.size > 0 || hasEsModule) {
path.unshiftContainer(
"body",
t.expressionStatement(