Skip to content

Commit e857cb3

Browse files
committed
fix: prioritize original sources over generated modules
1 parent 4cb57e5 commit e857cb3

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ __pycache__/
1111
.DS_Store
1212

1313
# Project
14+
*.txt
1415
/maps_list.txt
1516
/maps_files*
1617
/output*

‎decoder.py‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ def remove_first_slash(file_path: str) -> str:
5757
return file_path
5858

5959

60+
def is_generated_source_path(file_path: str) -> bool:
61+
return "/./" in file_path
62+
63+
6064
def save_decode_result(output_folder: Path, bundle_name: str, decode_result: source_maps.DecodeResult) -> None:
6165
folder_path = output_folder / bundle_name
6266
if not folder_path.exists():
@@ -72,8 +76,16 @@ def save_decode_result(output_folder: Path, bundle_name: str, decode_result: sou
7276

7377
# Папка в который лежит бандл, относительной данной папки, мы и будет сохранять файлы
7478
relative_folder_in_sm = Path(decode_result.sourceMapStatistic["sourceMapPath"]).parent
75-
for original_file_path, file_content in decode_result.files.items():
79+
80+
# Сборщик по-разному обозначает путь исходника и путь сгенерированного модуля.
81+
# После нормализации они совпадают, поэтому сначала сохраняем исходник.
82+
# Тогда суффикс дубликата получает сгенерированная версия.
83+
file_paths_to_save = sorted(decode_result.files, key=is_generated_source_path)
84+
85+
for original_file_path in file_paths_to_save:
86+
file_content = decode_result.files[original_file_path]
7687
file_path = original_file_path
88+
7789
if check_in_forbidden_symbols(file_path):
7890
forbidden_paths.append(file_path)
7991
print("[INFO]", f"Файл '{file_path}' был убран для сохранения")

0 commit comments

Comments
 (0)