Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle .map files during build #2591

Merged
merged 2 commits into from
Jul 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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