Description
Bug Report
🔎 Search Terms
SyntaxError: Named export not found. The requested module is a CommonJS module, which may not support all module.exports as named exports, esm, exports, __exportStar, tslib
🕗 Version & Regression Information
- This changed between versions 4.4 and 4.3
⏯ Playground Link
Playground links demonstrate the difference in compiled output between versions
Playground link with relevant code (4.4)
Playground link with relevant code (4.3)
Full reproduction repo and instructions
💻 Code
From the above Playground link, 4.4 produces:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
(0, tslib_1.__exportStar)(require("fs"), exports);
4.3 produces:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("fs"), exports);
Note the use of the comma operator to unbind __exportStar
. This seems to be new in 4.4 via more indirect calls for imported functions and #44624
🙁 Actual behavior
Named exports are missing when importing a CommonJS module compiled with Typescript 4.4 when importHelpers
is true
.
Setting importHelpers
to false fixes this problem, but may result in a lot of duplicated code via tslib
🙂 Expected behavior
Named exports should either exist, whether I have importHelpers
turned on or off.... or would be good this this was specifically documented as a breaking change.
(possibly) related: #45189