question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

plugin-transform-modules-commonjs: export binding not updated by 'for...in' and 'for...of'

See original GitHub issue

Bug Report

  • I would like to work on a fix!

Current Behavior If an exported binding is used as LHS in a ForOfStatement or ForInStatement, only the local variable is updated. The exported binding stays the same.

Input Code

export let foo = 'initial';

for (foo in {prop: 1}) {}

for (foo of ['element']) {}

for ({foo} of [{foo: 'destructured'}]) {}

Expected behavior/code exports.foo should be updated every time foo is assigned a new value. I tested the code without transpilation in Node.js and it works as expected.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vedantroycommented, Jan 20, 2020

I’ll take a shot at this.

0reactions
vedantroycommented, Jan 31, 2020
Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/plugin-transform-modules-commonjs
Side-effect imports are automatically non-lazy since their very existence means that there is no binding to later kick off initialization. export * from...
Read more >
@babel/plugin-transform-for-of | Yarn - Package Manager
babel-helper-module-transforms , babel-plugin-transform-modules-commonjs. #11074 Fix export bindings not updated by 'for ... in' and 'for ... of' ...
Read more >
javascript - What is the difference between ( for... in ) and ( for ...
In your example, the array iterator does yield all the values in the array (ignoring non-index properties). Share.
Read more >
for...of - JavaScript | MDN - MDN Web Docs
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include ...
Read more >
Migrating from Babel - SWC
npx babel # old $ npx swc # new ... babel-plugin-proposal-export-namespace-from, ✔️ ... babel-plugin-transform-modules-commonjs, ✔️.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found