1010from pathlib import Path
1111from typing import Any , List , NewType , Optional , Set , Tuple , Union , overload
1212
13- from idom .config import IDOM_DEBUG_MODE
13+ from idom .config import IDOM_DEBUG_MODE , IDOM_WED_MODULES_DIR
1414from idom .core .vdom import ImportSourceDict , VdomDictConstructor , make_vdom_constructor
1515
1616from .utils import (
17+ module_name_suffix ,
1718 resolve_module_exports_from_file ,
1819 resolve_module_exports_from_url ,
19- url_suffix ,
20- web_module_path ,
2120)
2221
2322
@@ -59,21 +58,21 @@ def module_from_template(
5958) -> WebModule :
6059 cdn = cdn .rstrip ("/" )
6160 template_file = (
62- Path (__file__ ).parent / "templates" / f"{ template } { url_suffix (name )} "
61+ Path (__file__ ).parent / "templates" / f"{ template } { module_name_suffix (name )} "
6362 )
6463
6564 if not template_file .exists ():
6665 raise ValueError (f"No template for { template !r} exists" )
6766
68- target_file = web_module_path (name )
67+ target_file = _web_module_path (name )
6968 if not target_file .exists ():
7069 target_file .parent .mkdir (parents = True , exist_ok = True )
7170 target_file .write_text (
7271 template_file .read_text ().replace ("$PACKAGE" , name ).replace ("$CDN" , cdn )
7372 )
7473
7574 return WebModule (
76- source = name ,
75+ source = name + module_name_suffix ( name ) ,
7776 source_type = NAME_SOURCE ,
7877 default_fallback = fallback ,
7978 file = target_file ,
@@ -93,15 +92,15 @@ def module_from_file(
9392 resolve_exports_depth : int = 5 ,
9493) -> WebModule :
9594 source_file = Path (file )
96- target_file = web_module_path (name )
95+ target_file = _web_module_path (name )
9796 if target_file .exists ():
9897 if target_file .resolve () != source_file .resolve ():
9998 raise ValueError (f"{ name !r} already exists as { target_file .resolve ()} " )
10099 else :
101100 target_file .parent .mkdir (parents = True , exist_ok = True )
102101 target_file .symlink_to (source_file )
103102 return WebModule (
104- source = name ,
103+ source = name + module_name_suffix ( name ) ,
105104 source_type = NAME_SOURCE ,
106105 default_fallback = fallback ,
107106 file = target_file ,
@@ -180,3 +179,9 @@ def _make_export(
180179 fallback = (fallback or web_module .default_fallback ),
181180 ),
182181 )
182+
183+
184+ def _web_module_path (name : str ) -> Path :
185+ name += module_name_suffix (name )
186+ path = IDOM_WED_MODULES_DIR .current .joinpath (* name .split ("/" ))
187+ return path .with_suffix (path .suffix )
0 commit comments