Skip to content

Commit 0001718

Browse files
test(vite-plugin-angular): pick main plugin from fastCompilePlugin pair
fastCompilePlugin now returns a [main, dts] plugin pair; update the fast-compile spec to drive the main plugin's transform hook.
1 parent a42fe9a commit 0001718

1 file changed

Lines changed: 44 additions & 30 deletions

File tree

packages/vite-plugin-angular/src/lib/fast-compile-plugin.spec.ts

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,27 @@ vi.mock('vite', async () => {
2222

2323
import { 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+
2533
function 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

3848
function 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

Comments
 (0)