Skip to content

Commit b49db94

Browse files
committed
Properly parse flat modules
1 parent ea79f99 commit b49db94

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

django_esm/utils.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,36 @@ def parse_package_json(path: Path = None):
9999
dependencies = package_json.get("dependencies", {})
100100
exports = cast_exports(package_json)
101101

102-
for module_name, module in exports.items():
103-
module = next(find_default_key(module))
104-
102+
try:
103+
module = exports["default"]
105104
yield from get_static_from_abs_path(
106-
str(Path(name) / module_name),
105+
str(Path(name) / module),
107106
path / module,
108107
settings.BASE_DIR / "node_modules",
109108
)
109+
if name == "lit-html":
110+
print("lit-html", module)
111+
except KeyError:
112+
try:
113+
module = exports["import"]
114+
yield from get_static_from_abs_path(
115+
name,
116+
path / module,
117+
settings.BASE_DIR / "node_modules",
118+
)
119+
if name == "lit-html":
120+
print("lit-html", module)
121+
except KeyError:
122+
for module_name, module in exports.items():
123+
if name == "lit-html":
124+
print("lit-html", module)
125+
module = next(find_default_key(module))
126+
127+
yield from get_static_from_abs_path(
128+
str(Path(name) / module_name),
129+
path / module,
130+
settings.BASE_DIR / "node_modules",
131+
)
110132

111133
for dep_name, dep_version in dependencies.items():
112134
dep_path = path

0 commit comments

Comments
 (0)