5.5.0 regression - Named exports of functions are not emitted for CommonJS
Knagis opened this issue · comments
Kārlis Gaņģis commented
🔎 Search Terms
commonjs export
🕗 Version & Regression Information
- This changed between versions 5.4.5 and 5.5.0
⏯ Playground Link
💻 Code
function foo(): void {
}
export {
foo,
};
🙁 Actual behavior
ts 5.5.0-beta and 5.5.0-dev-20240508 both emit:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.foo = void 0;
function foo() {
}
note missing last line
🙂 Expected behavior
ts 5.4.5 emit
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.foo = void 0;
function foo() {
}
exports.foo = foo;
Additional information about the issue
No response
Kārlis Gaņģis commented
the problem shows up only with functions. exporting classes or variables via export { foo }
work fine. also export function foo() {}
works fine.
Jake Bailey commented
Most likely this was #57669 (you could try using https://www.npmjs.com/package/every-ts to bisect and verify).
Kārlis Gaņģis commented
Bisect confirms that it is the cause
881f449a8a10839db5d535c3a407621d53c78666 is the first bad commit
commit 881f449a8a10839db5d535c3a407621d53c78666
Author: Ron Buckton
Date: Wed Mar 6 18:43:59 2024 -0500
Hoist function exports to top of module body in CJS/AMD/UMD (#57669)
Jake Bailey commented
Yeah, the issue appears to be that collectExternalModuleInfo
doesn't do the same thing it does for function declarations when processing export declarations.