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
Key words can't be used in comments #128
Comments
While I'd like it to be seamless, I'm also worried about the potential added complexity/runtime cost for proper detection. I go back and forth on whether it is worth it but I do suspect there could be a reasonable compromise (in terms of discovering if our triggers are in comments -- although if we do that, we need to ensure we have a magic string that we will match to accommodate those working around detection). So I'm definitely not ruling anything out and would hope to see better detection than what we have today. |
I've been giving this a bit of thought, and agree, seamless is better. I think the best way forward would be some additional regexes that are run after to ensure that the trigger is not in a comment, or a string. Beyond that, we should try to raise an exception with a good error message when this occurs? I don't know enough about sprockets internals and the interactions between it and browserify works to know if this is an option, but it seems like it'd be quite helpful. |
My way of thinking of Sprockets is we basically get stdin and stdout. The input comes from Sprockets after it has done some of it's things like |
Do we get exit codes? Or just the output? |
We can cause an error -- there is an example of an exception thrown in the processor when it doesn't find the browserify commands. I was assuming we'd be open in what we accept and gloss over false positives (just log them) but maybe that isn't a good idea. |
I like this idea, if I get a few spare moments this week I'll send a PR. |
Right now there are a few edge cases that will cause browserify-rails to fail in unexpected ways (which, because they're unexpected makes it hard to track down 😕)
JavaScript files including the words "module.export" or "require('something')" outside of the expected use – i.e. in a comment or string will stop browserify from working randomly, with no error leading to the problem.
Examples of cases that will cause failure:
I've helped this slightly with #125, but I think there's still a ways to go before this is resolved. Unfortunately, because this is parsing JavaScript with Ruby, there's no easy way to tell whether or not these key words are within comments or strings.
We can do a better job with the regexes that check for their presence and should add this gotcha to a visible place within the documentation.
The text was updated successfully, but these errors were encountered: