You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a file requires pre-processing (example CoffeeScript) I can't put processing directives in the file. This occurs because the file is first run through the filters, then checks for processing directives. But the filters usually remove comments and therefore remove processing directives.
I don't currently have a pull request as I need to focus on my project and I have a workaround. But I wanted to note the problem in case someone else wanted to tackle it.
I believe the solution is to extract the processing directives to come up with a list of files to run filters on. The file containing the processing directive is simply added to that list at the end. Then we process the list of files through the filters and concatenate the result together.
This might be an ideal time to add support for the "require_self" directive. Rather than sticking the the file that contains the processing directives at the end of the list we stick it in whatever position the "require_self" directive is located.
Currently I am working around this by having any files that contain processing directives be pure JS (so the comments aren't stripped). If I want to have some extra CoffeeScript on that file I just create a new file and include that. It works but creates more files than are necessary using the Rails asset pipeline.
The text was updated successfully, but these errors were encountered:
This is a known problem and is something I wondered how to tackle because, simply because Coffee etc doesn't have the right syntax for that. Sprockets hacks around it by allowing #= too (IIRC), which I'm not okay with.
We have several possibilities :
Don't add them.
This is what we currently have, and I'd really want to stick with it, considering how many times I've seen people ask "why am I getting duplicated deps?" when they require jQuery twice.
This is not commonjs/AMD (though you can very well use Sprockets with that), and should not be taken as such. I'm fine with application.js, usually.
Add regexps for each preprocessors so that they return array("processed code", array("directives"))
This is probably the worst we can do (mostly code-wise)
Allow /* *= */ and //= style comments everywhere
This has the the downside of looking terribly bad in preprocessors. Let's imagine we get support for a lisp dialect, I'd feel bad writing
If a file requires pre-processing (example CoffeeScript) I can't put processing directives in the file. This occurs because the file is first run through the filters, then checks for processing directives. But the filters usually remove comments and therefore remove processing directives.
I don't currently have a pull request as I need to focus on my project and I have a workaround. But I wanted to note the problem in case someone else wanted to tackle it.
I believe the solution is to extract the processing directives to come up with a list of files to run filters on. The file containing the processing directive is simply added to that list at the end. Then we process the list of files through the filters and concatenate the result together.
This might be an ideal time to add support for the "require_self" directive. Rather than sticking the the file that contains the processing directives at the end of the list we stick it in whatever position the "require_self" directive is located.
Currently I am working around this by having any files that contain processing directives be pure JS (so the comments aren't stripped). If I want to have some extra CoffeeScript on that file I just create a new file and include that. It works but creates more files than are necessary using the Rails asset pipeline.
The text was updated successfully, but these errors were encountered: