-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exported functions block array detection in plugin-transform-for-of #11415
Comments
Hey @skeggse! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite." |
This might be a bit hard to fix. In order to decide when to apply the "array-only" optimization, babel/packages/babel-traverse/src/path/inference/index.js Lines 114 to 120 in f6c7bf3
The
That inferencer then collects all the assignments done before using that variable: babel/packages/babel-traverse/src/path/inference/inferer-reference.js Lines 36 to 40 in f6c7bf3
The problem is that, since // a.js
import "./b.js";
var values = [1, 2, 3];
export function fn() {
console.log(values);
} // b.js
import { fn } from "./a.js";
fn(); If you run I see three possible solutions (in order of my preference, starting from the best one):
|
I like all of these solutions! 1 is acceptable to me, as are the rest. |
👍 I'm assigning this issue to you since you ticked "I would like to work on a fix!". If you need any help, feel free to ask either here or in our Slack! |
Bug Report
Current Behavior
A clear and concise description of the behavior.
Input Code
Expected behavior/code
A clear and concise description of what you expected to happen (or code).
Exported functions get the same treatment as far as array detection is concerned.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
Environment
cli
,rollup-plugin-babel
, or the online replPossible Solution
Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.
The text was updated successfully, but these errors were encountered: