From c9d7a3cbda5d30b9541595b306bbf407fa83020d Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Fri, 30 Jul 2021 11:25:50 +0200 Subject: [PATCH] Bundle .map files during build --- panel/compiler.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/panel/compiler.py b/panel/compiler.py index ce619d5384..7bbd083cd2 100644 --- a/panel/compiler.py +++ b/panel/compiler.py @@ -83,7 +83,6 @@ def require_components(): exports.append(export) return configs, requirements, exports, skip_import - def write_bundled_files(name, files, bundle_dir, explicit_dir=None, ext=None): model_name = name.split('.')[-1].lower() for bundle_file in files: @@ -94,8 +93,17 @@ def write_bundled_files(name, files, bundle_dir, explicit_dir=None, ext=None): try: response = requests.get(bundle_file, verify=False) except Exception as e: - print(f"Failed to fetch {name} dependency: {bundle_file}. Errored with {e}.") - continue + raise ConnectionError( + f"Failed to fetch {name} dependency: {bundle_file}. Errored with {e}." + ) + try: + map_file = f'{bundle_file}.map' + map_response = requests.get(map_file) + except Exception: + try: + map_response = requests.get(map_file, verify=False) + except Exception as e: + map_response = None bundle_path = os.path.join(*os.path.join(*bundle_file.split('//')[1:]).split('/')[1:]) obj_dir = explicit_dir or model_name filename = bundle_dir.joinpath(obj_dir, bundle_path) @@ -105,6 +113,9 @@ def write_bundled_files(name, files, bundle_dir, explicit_dir=None, ext=None): filename += f'.{ext}' with open(filename, 'w', encoding="utf-8") as f: f.write(response.content.decode('utf-8')) + if map_response: + with open(f'{filename}.map', 'w', encoding="utf-8") as f: + f.write(map_response.content.decode('utf-8')) def write_bundled_tarball(name, tarball, bundle_dir, module=False): model_name = name.split('.')[-1].lower()