@@ -25,11 +25,11 @@ pub struct TsConfig {
2525 /// Whether this is the caller tsconfig.
2626 /// Used for final template variable substitution when all configs are extended and merged.
2727 #[ serde( skip) ]
28- root : bool ,
28+ pub root : bool ,
2929
3030 /// Path to `tsconfig.json`. Contains the `tsconfig.json` filename.
3131 #[ serde( skip) ]
32- pub ( crate ) path : PathBuf ,
32+ pub path : PathBuf ,
3333
3434 #[ serde( default ) ]
3535 pub extends : Option < ExtendsField > ,
@@ -48,10 +48,10 @@ pub struct TsConfig {
4848#[ derive( Debug , Default , Deserialize ) ]
4949#[ serde( rename_all = "camelCase" ) ]
5050pub struct CompilerOptions {
51- base_url : Option < PathBuf > ,
51+ pub base_url : Option < PathBuf > ,
5252
5353 /// Path aliases
54- paths : Option < CompilerOptionsPathsMap > ,
54+ pub paths : Option < CompilerOptionsPathsMap > ,
5555
5656 /// The actual base for where path aliases are resolved from.
5757 #[ serde( skip) ]
@@ -73,7 +73,21 @@ pub struct ProjectReference {
7373}
7474
7575impl TsConfig {
76- pub fn parse ( root : bool , path : & Path , json : & mut str ) -> Result < Self , serde_json:: Error > {
76+ /// Directory to `tsconfig.json`
77+ ///
78+ /// # Panics
79+ ///
80+ /// * When the `tsconfig.json` path is misconfigured.
81+ pub fn directory ( & self ) -> & Path {
82+ debug_assert ! ( self . path. file_name( ) . is_some( ) ) ;
83+ self . path . parent ( ) . unwrap ( )
84+ }
85+
86+ pub ( crate ) fn parse (
87+ root : bool ,
88+ path : & Path ,
89+ json : & mut str ,
90+ ) -> Result < Self , serde_json:: Error > {
7791 _ = json_strip_comments:: strip ( json) ;
7892 let mut tsconfig: Self = serde_json:: from_str ( json) ?;
7993 tsconfig. root = root;
@@ -89,7 +103,7 @@ impl TsConfig {
89103 Ok ( tsconfig)
90104 }
91105
92- pub fn build ( mut self ) -> Self {
106+ pub ( crate ) fn build ( mut self ) -> Self {
93107 if self . root {
94108 let dir = self . directory ( ) . to_path_buf ( ) ;
95109 // Substitute template variable in `tsconfig.compilerOptions.paths`
@@ -104,17 +118,7 @@ impl TsConfig {
104118 self
105119 }
106120
107- /// Directory to `tsconfig.json`
108- ///
109- /// # Panics
110- ///
111- /// * When the `tsconfig.json` path is misconfigured.
112- pub fn directory ( & self ) -> & Path {
113- debug_assert ! ( self . path. file_name( ) . is_some( ) ) ;
114- self . path . parent ( ) . unwrap ( )
115- }
116-
117- pub fn extend_tsconfig ( & mut self , tsconfig : & Self ) {
121+ pub ( crate ) fn extend_tsconfig ( & mut self , tsconfig : & Self ) {
118122 let compiler_options = & mut self . compiler_options ;
119123 if compiler_options. paths . is_none ( ) {
120124 compiler_options. paths_base = compiler_options
@@ -128,7 +132,7 @@ impl TsConfig {
128132 }
129133 }
130134
131- pub fn resolve ( & self , path : & Path , specifier : & str ) -> Vec < PathBuf > {
135+ pub ( crate ) fn resolve ( & self , path : & Path , specifier : & str ) -> Vec < PathBuf > {
132136 if path. starts_with ( self . base_path ( ) ) {
133137 let paths = self . resolve_path_alias ( specifier) ;
134138 if !paths. is_empty ( ) {
@@ -145,7 +149,7 @@ impl TsConfig {
145149
146150 // Copied from parcel
147151 // <https://github.com/parcel-bundler/parcel/blob/b6224fd519f95e68d8b93ba90376fd94c8b76e69/packages/utils/node-resolver-rs/src/tsconfig.rs#L93>
148- pub fn resolve_path_alias ( & self , specifier : & str ) -> Vec < PathBuf > {
152+ pub ( crate ) fn resolve_path_alias ( & self , specifier : & str ) -> Vec < PathBuf > {
149153 if specifier. starts_with ( [ '/' , '.' ] ) {
150154 return vec ! [ ] ;
151155 }
0 commit comments