Skip to content

Commit

Permalink
Properly parse flat modules
Browse files Browse the repository at this point in the history
  • Loading branch information
codingjoe committed Jan 25, 2024
1 parent ea79f99 commit b49db94
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions django_esm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,36 @@ def parse_package_json(path: Path = None):
dependencies = package_json.get("dependencies", {})
exports = cast_exports(package_json)

for module_name, module in exports.items():
module = next(find_default_key(module))

try:
module = exports["default"]
yield from get_static_from_abs_path(
str(Path(name) / module_name),
str(Path(name) / module),
path / module,
settings.BASE_DIR / "node_modules",
)
if name == "lit-html":
print("lit-html", module)
except KeyError:
try:
module = exports["import"]
yield from get_static_from_abs_path(
name,
path / module,
settings.BASE_DIR / "node_modules",
)
if name == "lit-html":
print("lit-html", module)
except KeyError:
for module_name, module in exports.items():
if name == "lit-html":
print("lit-html", module)
module = next(find_default_key(module))

yield from get_static_from_abs_path(
str(Path(name) / module_name),
path / module,
settings.BASE_DIR / "node_modules",
)

for dep_name, dep_version in dependencies.items():
dep_path = path
Expand Down

0 comments on commit b49db94

Please sign in to comment.