Skip to content

Commit

Permalink
Bundle .map files during build (#2591)
Browse files Browse the repository at this point in the history
* Bundle .map files during build

* Fix flakes
  • Loading branch information
philippjfr authored Jul 30, 2021
1 parent 396d814 commit a5c367f
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions panel/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
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)
Expand All @@ -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()
Expand Down

0 comments on commit a5c367f

Please sign in to comment.