@@ -44,6 +44,7 @@ fn enhanced_transform_internal(
4444 source_text : & str ,
4545 options : Option < BindingEnhancedTransformOptions > ,
4646 cache : Option < & TsconfigCache > ,
47+ yarn_pnp : bool ,
4748) -> napi:: Result < BindingEnhancedTransformResult > {
4849 let options = options. unwrap_or_default ( ) ;
4950 let cwd = options
@@ -59,7 +60,7 @@ fn enhanced_transform_internal(
5960 ) ) ;
6061 }
6162
62- let result = core_enhanced_transform ( filename, source_text, transform_options) ;
63+ let result = core_enhanced_transform ( filename, source_text, transform_options, yarn_pnp ) ;
6364 Ok ( BindingEnhancedTransformResult :: from_enhanced_transform_result ( result, cwd) )
6465}
6566
@@ -68,6 +69,7 @@ pub struct EnhancedTransformTask<'a> {
6869 source_text : String ,
6970 options : Option < BindingEnhancedTransformOptions > ,
7071 cache : Option < & ' a TsconfigCache > ,
72+ yarn_pnp : bool ,
7173}
7274
7375#[ napi]
@@ -76,71 +78,49 @@ impl Task for EnhancedTransformTask<'_> {
7678 type Output = BindingEnhancedTransformResult ;
7779
7880 fn compute ( & mut self ) -> napi:: Result < Self :: Output > {
79- enhanced_transform_internal ( & self . filename , & self . source_text , self . options . take ( ) , self . cache )
81+ enhanced_transform_internal (
82+ & self . filename ,
83+ & self . source_text ,
84+ self . options . take ( ) ,
85+ self . cache ,
86+ self . yarn_pnp ,
87+ )
8088 }
8189
8290 fn resolve ( & mut self , _env : napi:: Env , output : Self :: Output ) -> napi:: Result < Self :: JsValue > {
8391 Ok ( output)
8492 }
8593}
8694
87- /// Transpile a JavaScript or TypeScript into a target ECMAScript version, asynchronously.
88- ///
89- /// Note: This function can be slower than `transformSync` due to the overhead of spawning a thread.
90- ///
91- /// @param filename The name of the file being transformed. If this is a
92- /// relative path, consider setting the {@link TransformOptions#cwd} option.
93- /// @param sourceText The source code to transform.
94- /// @param options The transform options including tsconfig and inputMap. See {@link
95- /// BindingEnhancedTransformOptions} for more information.
96- /// @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
97- /// Only used when tsconfig auto-discovery is enabled.
98- ///
99- /// @returns a promise that resolves to an object containing the transformed code,
100- /// source maps, and any errors that occurred during parsing or transformation.
101- ///
102- /// @experimental
10395#[ napi]
10496pub fn enhanced_transform (
10597 filename : String ,
10698 source_text : String ,
10799 options : Option < BindingEnhancedTransformOptions > ,
108100 cache : Option < & TsconfigCache > ,
101+ yarn_pnp : bool ,
109102) -> AsyncTask < EnhancedTransformTask < ' _ > > {
110- AsyncTask :: new ( EnhancedTransformTask { filename, source_text, options, cache } )
103+ AsyncTask :: new ( EnhancedTransformTask { filename, source_text, options, cache, yarn_pnp } )
111104}
112105
113- /// Transpile a JavaScript or TypeScript into a target ECMAScript version.
114- ///
115- /// @param filename The name of the file being transformed. If this is a
116- /// relative path, consider setting the {@link TransformOptions#cwd} option.
117- /// @param sourceText The source code to transform.
118- /// @param options The transform options including tsconfig and inputMap. See {@link
119- /// BindingEnhancedTransformOptions} for more information.
120- /// @param cache Optional tsconfig cache for reusing resolved tsconfig across multiple transforms.
121- /// Only used when tsconfig auto-discovery is enabled.
122- ///
123- /// @returns an object containing the transformed code, source maps, and any errors
124- /// that occurred during parsing or transformation.
125- ///
126- /// @experimental
127106#[ napi]
128107pub fn enhanced_transform_sync (
129108 filename : String ,
130109 source_text : String ,
131110 options : Option < BindingEnhancedTransformOptions > ,
132111 cache : Option < & TsconfigCache > ,
112+ yarn_pnp : bool ,
133113) -> napi:: Result < BindingEnhancedTransformResult > {
134- enhanced_transform_internal ( & filename, & source_text, options, cache)
114+ enhanced_transform_internal ( & filename, & source_text, options, cache, yarn_pnp )
135115}
136116
137- /// @hidden This is only expected to be used by Vite
138117#[ napi]
139118pub fn resolve_tsconfig (
140119 filename : String ,
141120 cache : Option < & TsconfigCache > ,
121+ yarn_pnp : bool ,
142122) -> napi:: Result < Option < BindingTsconfigResult > > {
143- let tsconfig_cache = if let Some ( cache) = cache { cache } else { & TsconfigCache :: new ( ) } ;
123+ let tsconfig_cache = if let Some ( cache) = cache { cache } else { & TsconfigCache :: new ( yarn_pnp ) } ;
144124
145125 match tsconfig_cache. find_tsconfig ( Path :: new ( & filename) ) {
146126 Ok ( Some ( tsconfig) ) => Ok ( Some ( tsconfig. as_ref ( ) . clone ( ) . into ( ) ) ) ,
0 commit comments