@@ -22,17 +22,27 @@ vi.mock('vite', async () => {
2222
2323import { fastCompilePlugin } from './fast-compile-plugin' ;
2424
25+ // `fastCompilePlugin` returns a [main, dts] plugin pair; these tests drive the
26+ // main plugin's transform hook.
27+ const FAST_COMPILE_PLUGIN_NAME = '@analogjs/vite-plugin-angular-fast-compile' ;
28+
29+ function pickMainPlugin ( result : ReturnType < typeof fastCompilePlugin > ) {
30+ return result . find ( ( p ) => p . name === FAST_COMPILE_PLUGIN_NAME ) ! ;
31+ }
32+
2533function buildPlugin ( ) {
26- return fastCompilePlugin ( {
27- tsconfigGetter : ( ) => 'tsconfig.json' ,
28- workspaceRoot : '/workspace' ,
29- inlineStylesExtension : 'css' ,
30- jit : false ,
31- liveReload : false ,
32- supportedBrowsers : [ ] ,
33- isTest : false ,
34- isAstroIntegration : false ,
35- } ) ;
34+ return pickMainPlugin (
35+ fastCompilePlugin ( {
36+ tsconfigGetter : ( ) => 'tsconfig.json' ,
37+ workspaceRoot : '/workspace' ,
38+ inlineStylesExtension : 'css' ,
39+ jit : false ,
40+ liveReload : false ,
41+ supportedBrowsers : [ ] ,
42+ isTest : false ,
43+ isAstroIntegration : false ,
44+ } ) ,
45+ ) ;
3646}
3747
3848function getTransformHandler ( plugin : ReturnType < typeof buildPlugin > ) {
@@ -142,16 +152,18 @@ describe('fastCompilePlugin bypass strips TS', () => {
142152 map : { mappings : '' } ,
143153 } ) ;
144154
145- const plugin = fastCompilePlugin ( {
146- tsconfigGetter : ( ) => 'tsconfig.json' ,
147- workspaceRoot : '/workspace' ,
148- inlineStylesExtension : 'css' ,
149- jit : true ,
150- liveReload : false ,
151- supportedBrowsers : [ ] ,
152- isTest : true ,
153- isAstroIntegration : false ,
154- } ) ;
155+ const plugin = pickMainPlugin (
156+ fastCompilePlugin ( {
157+ tsconfigGetter : ( ) => 'tsconfig.json' ,
158+ workspaceRoot : '/workspace' ,
159+ inlineStylesExtension : 'css' ,
160+ jit : true ,
161+ liveReload : false ,
162+ supportedBrowsers : [ ] ,
163+ isTest : true ,
164+ isAstroIntegration : false ,
165+ } ) ,
166+ ) ;
155167 const handler = getTransformHandler ( plugin ) ;
156168
157169 const code = `import { Component } from '@angular/core';
@@ -196,16 +208,18 @@ export class App {
196208 configurable : true ,
197209 } ) ;
198210 try {
199- const plugin = fastCompilePlugin ( {
200- tsconfigGetter : ( ) => 'tsconfig.json' ,
201- workspaceRoot : '/workspace' ,
202- inlineStylesExtension : 'css' ,
203- jit : true ,
204- liveReload : false ,
205- supportedBrowsers : [ ] ,
206- isTest : true ,
207- isAstroIntegration : false ,
208- } ) ;
211+ const plugin = pickMainPlugin (
212+ fastCompilePlugin ( {
213+ tsconfigGetter : ( ) => 'tsconfig.json' ,
214+ workspaceRoot : '/workspace' ,
215+ inlineStylesExtension : 'css' ,
216+ jit : true ,
217+ liveReload : false ,
218+ supportedBrowsers : [ ] ,
219+ isTest : true ,
220+ isAstroIntegration : false ,
221+ } ) ,
222+ ) ;
209223 const handler = getTransformHandler ( plugin ) ;
210224
211225 const code = `import { Component } from '@angular/core';
0 commit comments