-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Raise an error when javascript_pack_tag or stylesheet_pack_tag are called more than once #3083
Raise an error when javascript_pack_tag or stylesheet_pack_tag are called more than once #3083
Conversation
83da568
to
1782dd8
Compare
…lled more than once
1782dd8
to
6769558
Compare
lib/webpacker/helper.rb
Outdated
@@ -96,6 +96,9 @@ def favicon_pack_tag(name, **options) | |||
# <%= javascript_pack_tag 'calendar' %> | |||
# <%= javascript_pack_tag 'map' %> | |||
def javascript_pack_tag(*names, **options) | |||
raise "To prevent duplicated chunks on the page, you should call javascript_pack_tag only once on the page." if defined?(@javascript_pack_tag_loaded) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of raising an error that says "you shouldn't do this", is it possible to link to some kind of documentation that explains why this restriction is in place and a couple of ways the developer can resolve this? For instance, the new section that is getting added to the Usage section in the README. This is a change in behavior from the existing behavior in v5, so my fear is that even people who have been keeping up with the changes in the beta will be frustrated upon receiving this error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. This is a fairly strong reaction to something that will not crash an app, but only cause rendering issues.
For the record we could link to the section added by #3084.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can do that for sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guillaumebriday How about if we raise by default for Rails.env.test? and Rails.env and warn otherwise?
This could use a test. |
Yep, need to add some tests |
Feel free to reopen this PR here: |
Continue here: shakacode/shakapacker#17 |
fix #3068