-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35451 from dimagi/jls/discard-ancestor-js-bundle-…
…tags Improve handling of conflicting js bundle tools
- Loading branch information
Showing
2 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ | |
) | ||
from corehq.apps.hqwebapp.models import Alert | ||
from corehq.motech.utils import pformat_json | ||
from corehq.util.soft_assert import soft_assert | ||
from corehq.util.timezones.conversions import ServerTime | ||
from corehq.util.timezones.utils import get_timezone | ||
|
||
|
@@ -733,15 +734,20 @@ def __repr__(self): | |
|
||
def render(self, context): | ||
if self.name not in context and self.value: | ||
# Check that there isn't already an entry point from the other bundler tool | ||
# If there is, don't add this one, because having both set will cause js errors | ||
other_tag = "js_entry" if self.name == "requirejs_main" else "requirejs_main" | ||
other_value = None | ||
for context_dict in context.dicts: | ||
if other_tag in context_dict: | ||
other_value = context_dict.get(other_tag) | ||
msg = f"Discarding {self.value} {self.name} value because {other_value} is using {other_tag}" | ||
soft_assert('[email protected]', notify_admins=False, send_to_ops=False)(False, msg) | ||
# set name in block parent context | ||
other_name = "js_entry" if self.name == "requirejs_main" else "requirejs_main" | ||
other_values = [d.get(other_name) for d in context.dicts if other_name in d] | ||
if any(other_values): | ||
raise TemplateSyntaxError(f""" | ||
Cannot use both {self.name} ({self.value}) and {other_name} ({other_values[0]}) | ||
""".strip()) | ||
context.dicts[-2]['use_js_bundler'] = True | ||
context.dicts[-2][self.name] = self.value | ||
if not other_value: | ||
context.dicts[-2]['use_js_bundler'] = True | ||
context.dicts[-2][self.name] = self.value | ||
|
||
return '' | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters