# HG changeset patch # User Goffi # Date 1588527140 -7200 # Node ID 0b269d4a46a363abf87dd05f6d640dff5e9b0ea2 # Parent 92ff09cdd6ddca7f38fe228367b3c6757fc214d0 task (js_modules): handle `extra_init`: if `extra_init` is found in module metadata's `brython_map`, it is added at the end of the generated module, and `{build_dir}` is replaced by actual build dir if present. diff -r 92ff09cdd6dd -r 0b269d4a46a3 libervia/server/tasks/implicit/task_js_modules.py --- a/libervia/server/tasks/implicit/task_js_modules.py Sun May 03 19:28:14 2020 +0200 +++ b/libervia/server/tasks/implicit/task_js_modules.py Sun May 03 19:32:20 2020 +0200 @@ -58,6 +58,7 @@ module_data['path'] = Path('node_modules') / js_path.strip(' /') export = module_data.get('export') or [module_name] export_objects = '\n'.join(f'{e} = window.{e}' for e in export) + extra_kwargs = {"build_dir": C.BUILD_DIR} with module_path.open('w') as f: f.write(f"""\ @@ -67,5 +68,5 @@ load("{Path('/').joinpath(C.BUILD_DIR, module_data['path'])}") {export_objects} -{module_data.get('extra_init', '')} +{module_data.get('extra_init', '').format(**extra_kwargs)} """)