feat: allow to set main JS and CSS from files + lazy-load component m… (#870)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Juro Oravec 2024-12-30 18:00:46 +01:00 committed by GitHub
parent 8fcb84c002
commit 715bf7d447
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 1014 additions and 248 deletions

View file

@ -220,7 +220,7 @@ def _filepath_to_python_module(
# Combine with the base module path
full_module_name = f"{root_module_path}.{module_name}" if root_module_path else module_name
if full_module_name.endswith(".__init__"):
full_module_name = full_module_name[:-9] # Remove the trailing `.__init__
full_module_name = full_module_name[:-9] # Remove the trailing `.__init__`
return full_module_name
@ -236,3 +236,12 @@ def _search_dirs(dirs: List[Path], search_glob: str) -> List[Path]:
matched_files.append(Path(path))
return matched_files
def resolve_file(filepath: str, dirs: Optional[List[Path]] = None) -> Optional[Path]:
dirs = dirs if dirs is not None else get_component_dirs()
for directory in dirs:
full_path = Path(directory) / filepath
if full_path.exists():
return full_path
return None