You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The output is identical with babel, and typescript uses its __importDefault in a different order. Sucrase only applies the _interopRequireDefault in the first example.
IMO, the sucrase transformed code should be as follows:
Hi @forivall , thanks for reporting! I agree that this is a bug. To be clear, the impact is that the re-export won't work correctly if "bar" is a regular CJS module, e.g. if it has a line like module.exports = "Hello";. I'm a bit busy at the moment, but may be able to find some time for it, or a PR would be welcome. There was already a similar fix in #619 (which is why the two-line version works), so the fix would probably be something similar.
(A separate but related issue is whether to use live bindings vs a plain export assignment for the two-line version. That came up in #715 (comment) , and I have some hesitation with switching the behavior due to possible backcompat issues, though it might be fine.)
No worries on timing. The issue doesnt impact anything at the moment, I just noticed when making notes of all of the quirks of sucrase that I need to be aware of.
As far as the transitive binding, I think the export {...} from should use live bindings, since that's what tsc does (even for legacy interop), but tsc doesn't do live bindings for the 2 line export.
Ideally, there should be flags for this, although, that does introduce maintenance burden.
The two source files should generate equivalent imports transformation:
Sandbox
Sandbox
The output is identical with babel, and typescript uses its
__importDefault
in a different order. Sucrase only applies the_interopRequireDefault
in the first example.IMO, the sucrase transformed code should be as follows:
(unless
enableLegacyTypeScriptModuleInterop
is enabled, obvi)The text was updated successfully, but these errors were encountered: