plugin-transform-modules-commonjs: export binding not updated by 'for...in' and 'for...of'
See original GitHub issueBug 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:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll take a shot at this.
PR: https://github.com/babel/babel/pull/11074