feat(DX): sourceURL for injected javascript

Adds sourceURL to injected javascript code, this helps in debugging
injected javascript using client script or doctype specific javascript.

`no-docs`

(cherry picked from commit 8dd925743c)
This commit is contained in:
Ankush Menat 2021-04-26 22:16:18 +05:30 committed by mergify-bot
parent 38faf57dcd
commit fabe6d72ab

View file

@ -109,8 +109,9 @@ class FormMeta(Meta):
def _add_code(self, path, fieldname):
js = get_js(path)
if js:
self.set(fieldname, (self.get(fieldname) or "")
+ "\n\n/* Adding {0} */\n\n".format(path) + js)
comment = f"\n\n/* Adding {path} */\n\n"
sourceURL = f"\n\n//# sourceURL={scrub(self.name) + fieldname}"
self.set(fieldname, (self.get(fieldname) or "") + comment + js + sourceURL)
def add_html_templates(self, path):
if self.custom:
@ -145,6 +146,10 @@ class FormMeta(Meta):
if script.view == 'Form':
form_script += script.script
file = scrub(self.name)
form_script += f"\n\n//# sourceURL={file}__custom_js"
list_script += f"\n\n//# sourceURL={file}__custom_list_js"
self.set("__custom_js", form_script)
self.set("__custom_list_js", list_script)