-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
equally named private methods in different files break on merge #2319
Comments
Hey @Cxarli! 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 is expected. We should state clearly such limitations on https://babeljs.io/docs/en/babel-cli#compile-directories |
Hey @Cxarli! We really appreciate you taking the time to report an issue. The collaborators If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack |
I guess it can be expected if you manually write duplicate global variables/functions. However, this issue seems to be about code generated by I'm not sure what could be a waterproof solution here, but I was thinking maybe the plugin could prepend the class name in front of the WeakSet and the private method converted to global function, so they are named like |
Bug Report
If you have two files, each with a different class, but the classes share a method with the same name, the merged output file breaks because of name overlap.
Input Code
Also see this repo
Run Command
npx babel A.js B.js main.js -o out.js
Output Code
(slightly trimmed to make it clearer what the issue is, not actual output)
Expected behavior
The second pair should get unique names, so they don't clash, which would make the result
"A private"
Babel Configuration
babel.config.js
Environment
Possible Solution
Technically you can first concat the files before putting it through babel with
npx babel <(cat A.js B.js main.js) -o out.js
which means they are in the same scope and get unique functions and everything works. However, then you lose all source information (file, line) in case of errors.The text was updated successfully, but these errors were encountered: