Skip to content
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

unclarity/bug when using rails-erb-loader-dependencies directive in non-js files #107

Open
bertBruynooghe opened this issue Dec 15, 2021 · 2 comments

Comments

@bertBruynooghe
Copy link
Contributor

bertBruynooghe commented Dec 15, 2021

I spent quite some time figuring out I needed the following syntax to get dependencies detected for my .html.erb files:

<!-- /* rails-erb-loader-dependencies ... */ -->

I see two solutions:

  1. document this properly
  2. iso. /* rails-erb-loader-dependencies ... */ implement searching for: rails-erb-loader-dependencies (which allows users to use the proper comment syntax for the resulting file, and which is backwards compatible)

It would also be fine if we could support <%# rails-erb-loader-dependencies ... %>, which leaves no traces in the end result, and would also work for stuff that doesn't support comments (e.g. .json.erb)

I am willing to create a PR for this if you decide which of the two solutions you prefer...

@PikachuEXE
Copy link
Collaborator

I think we should simply update doc on https://github.com/usabilityhub/rails-erb-loader#dependencies
for this special case.
I have never used rails-erb-loader-dependencies in .html.erb so I have no idea that syntax is required.
(I don't even know how it works and I have only contributed a few things 😆 )

@rhys-vdw
Copy link
Collaborator

rhys-vdw commented May 12, 2022

If you don't want the directive to end up in the result, or wish to use it outside of a javascript context,
include the javascript comment block inside an erb comment block.

The reason this was not included in the docs is because comments should be removed in minification in your release build (same goes for all preprocessor directive comments, eslint etc etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants