Intermittent Parse Error on Plugin Rebuild

AI-generated summary

The discussion revolves around an intermittent parse error that occurs when rebuilding a plugin. Ghan describes the error as only happening when updating or rebuilding the plugin, but not every time. The error is related to a JS file added in a bbcode plugin, and Ghan shares a repository link (https://github.com/Ghan04/discourse-rpn-bbcode) for further investigation.

Ghan mentions that removing the default assignment in a function definition seems to resolve the issue, but is unsure why this would break the parser. merefield suggests that the issue might be due to the file extension not being recognized as ES6, and proposes changing the suffix to test this hypothesis. TheDarkWizard questions whether Discourse is supposed to always assume ES6, and tags the @team for further clarification.

In working on a bbcode plugin, we’re seeing an error appear related to one of the JS files we’ve added. This error only appears when updating the plugin or rebuilding the container, but does not occur every time. If I update the plugin via the admin UI and it fails, re-running the same upgrade again without making any changes will then succeed.

Any ideas what is going on here?

Might help if you shared the repo.

The repo is here:
https://github.com/Ghan04/discourse-rpn-bbcode

We’ve removed the default assignment in the function definition and it seems to behave better, but that shouldn’t be necessary as far as I can tell. Why would that break the parser?

Just a guess: is it not interpreting the file as es6 because the file extension is .js? If you change the suffix, does it make a difference? (You’d need to replace a default parameter to test this obviously.)

If that’s the case then there’s an issue with core? It should always be assuming it’s es6?

@team Is it always supposed to be assuming it’s es6?