-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Bug: Private method in Stimulus controllers causes SyntaxError: Private field must be declared in an enclosing class
when minified
#1295
Comments
It looks like the private field declarations get deleted upon minification. This could explain the issue, but then it wouldn't explain why the pie chart, which has a similar controller with private fields, does work. |
@gariasf exactly. The pie chart controller appears (for now) to work, which invalidates a lot of my initial thoughts on why this causes errors: |
@zachgoll There is one difference between the scripts, the one that breaks, the line chart controller, is missing semicolons on the imports. |
Oh, and the static object with the values is missing the semicolon as well. That should not be an issue, though… |
@gariasf good eye! I wasn't even paying attention to the imports; too distracted by the code itself! The pie chart controller does have semicolons on the imports, which explains why that file works fine when minified. I think ultimately what this tells me is that we need to start linting these controller files in CI / auto-formatting locally :) |
created #1299 for this |
Fixed via #1299 |
Note: a temporary fix has been added for this issue by removing all private method syntax and using underscores instead, but it would be nice to identify the root cause of this
Describe the bug
A clear and concise description of what the bug is.
This bug only occurs in production when Stimulus controllers are minified.
For example, the linked controller produces the following error:
SyntaxError: Private field '#updateView' must be declared in an enclosing class
Here is the original file:
https://github.com/maybe-finance/maybe/blob/c5bf1db230122066571b018ed417d132e6e7e446/app/javascript/controllers/bulk_select_controller.js
And here is the minified source served in production environments:
Expected behavior
A clear and concise description of what you expected to happen.
Private methods should be supported in all modern browsers.
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: