5
5
from tempfile import TemporaryDirectory
6
6
from typing import Dict , Iterable , List , Sequence , Set , Union
7
7
8
- from idom .config import IDOM_CLIENT_WEB_MODULE_BASE_URL
8
+ from idom .config import IDOM_CLIENT_BUILD_DIR , IDOM_CLIENT_WEB_MODULE_BASE_URL
9
9
10
10
from . import _private
11
11
12
12
13
13
logger = getLogger (__name__ )
14
14
15
15
16
+ def web_modules_dir () -> Path :
17
+ return IDOM_CLIENT_BUILD_DIR .get () / "_snowpack" / "pkg"
18
+
19
+
20
+ def web_module_path (package_name : str , must_exist : bool = False ) -> Path :
21
+ path = web_modules_dir ().joinpath (* (package_name + ".js" ).split ("/" ))
22
+ if must_exist and not path .exists ():
23
+ raise ValueError (
24
+ f"Web module { package_name !r} does not exist at path { str (path )!r} "
25
+ )
26
+ return path
27
+
28
+
16
29
def web_module_exports (package_name : str ) -> List [str ]:
17
30
web_module_path (package_name , must_exist = True )
18
31
return _private .find_js_module_exports_in_source (
@@ -31,7 +44,7 @@ def web_module_exists(package_name: str) -> bool:
31
44
32
45
def web_module_names () -> Set [str ]:
33
46
names = []
34
- web_mod_dir = _private . web_modules_dir ()
47
+ web_mod_dir = web_modules_dir ()
35
48
for pth in web_mod_dir .glob ("**/*.js" ):
36
49
rel_pth = pth .relative_to (web_mod_dir )
37
50
if Path ("common" ) in rel_pth .parents :
@@ -53,15 +66,6 @@ def add_web_module(package_name: str, source: Union[Path, str]) -> str:
53
66
return web_module_url (package_name )
54
67
55
68
56
- def web_module_path (package_name : str , must_exist : bool = False ) -> Path :
57
- path = _private .web_modules_dir ().joinpath (* (package_name + ".js" ).split ("/" ))
58
- if must_exist and not path .exists ():
59
- raise ValueError (
60
- f"Web module { package_name !r} does not exist at path { str (path )!r} "
61
- )
62
- return path
63
-
64
-
65
69
def restore () -> None :
66
70
_private .restore_build_dir_from_backup ()
67
71
0 commit comments