Skip to content

Commit 744ed1f

Browse files
fix(vite-plugin-angular): remove check for Vitest command in watch mode (#1606)
1 parent 16e6ba9 commit 744ed1f

File tree

19 files changed

+108
-122
lines changed

19 files changed

+108
-122
lines changed

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ pnpm-lock.yaml
1010
*.analog
1111
/.nx/workspace-data
1212
/packages/create-analog/template-*
13+
.vite-inspect

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
3+
"trailingComma": "all",
34
"overrides": [
45
{
56
"files": "*.md",

apps/analog-app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

apps/analog-app/src/app/pages/newsletter.page.ts

+18-19
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ type FormErrors =
1616
<h3>Newsletter Signup</h3>
1717
1818
@if (!signedUp()) {
19-
<form
20-
method="post"
21-
(onSuccess)="onSuccess()"
22-
(onError)="onError($any($event))"
23-
(onStateChange)="errors.set(undefined)"
24-
>
25-
<div>
26-
<label for="email"> Email </label>
27-
<input type="email" name="email" />
28-
</div>
29-
30-
<button class="button" type="submit">Submit</button>
31-
</form>
32-
33-
@if (errors()?.email) {
34-
<p>{{ errors()?.email }}</p>
35-
}
36-
} @else {
37-
<div>Thanks for signing up!</div>
19+
<form
20+
method="post"
21+
(onSuccess)="onSuccess()"
22+
(onError)="onError($any($event))"
23+
(onStateChange)="errors.set(undefined)"
24+
>
25+
<div>
26+
<label for="email"> Email </label>
27+
<input type="email" name="email" />
28+
</div>
29+
30+
<button class="button" type="submit">Submit</button>
31+
</form>
32+
33+
@if (errors()?.email) {
34+
<p>{{ errors()?.email }}</p>
35+
} } @else {
36+
<div>Thanks for signing up!</div>
3837
}
3938
`,
4039
})

apps/analog-app/src/app/pages/search.page.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { load } from './search.server';
2020
</form>
2121
2222
@if (searchTerm()) {
23-
<p>Search Term: {{ searchTerm() }}</p>
23+
<p>Search Term: {{ searchTerm() }}</p>
2424
}
2525
`,
2626
})

apps/blog-app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

apps/docs-app/docs/guides/forms.md

+19-20
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,24 @@ type FormErrors =
4444
<h3>Newsletter Signup</h3>
4545
4646
@if (!signedUp()) {
47-
<form
48-
method="post"
49-
(onSuccess)="onSuccess()"
50-
(onError)="onError($any($event))"
51-
(onStateChange)="errors.set(undefined)"
52-
>
53-
<div>
54-
<label for="email"> Email </label>
55-
<input type="email" name="email" />
56-
</div>
57-
58-
<button class="button" type="submit">Submit</button>
59-
</form>
60-
61-
@if (errors()?.email) {
62-
<p>{{ errors()?.email }}</p>
63-
}
64-
} @else {
65-
<div>Thanks for signing up!</div>
47+
<form
48+
method="post"
49+
(onSuccess)="onSuccess()"
50+
(onError)="onError($any($event))"
51+
(onStateChange)="errors.set(undefined)"
52+
>
53+
<div>
54+
<label for="email"> Email </label>
55+
<input type="email" name="email" />
56+
</div>
57+
58+
<button class="button" type="submit">Submit</button>
59+
</form>
60+
61+
@if (errors()?.email) {
62+
<p>{{ errors()?.email }}</p>
63+
} } @else {
64+
<div>Thanks for signing up!</div>
6665
}
6766
`,
6867
})
@@ -179,7 +178,7 @@ import type { load } from './search.server';
179178
</form>
180179
181180
@if (searchTerm()) {
182-
<p>Search Term: {{ searchTerm() }}</p>
181+
<p>Search Term: {{ searchTerm() }}</p>
183182
}
184183
`,
185184
})

apps/ng-app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
33
<head>
44
<meta charset="utf-8" />

apps/trpc-app/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html class="dark h-full" lang="en">
33
<head>
44
<meta charset="utf-8" />

libs/card/src/lib/autocomplete/autocomplete.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/>
1111
<mat-autocomplete #autocomplete="matAutocomplete" autoActiveFirstOption>
1212
@for (option of filteredOptions(); track option) {
13-
<mat-option [value]="option.value">{{ option.label }}</mat-option>
13+
<mat-option [value]="option.value">{{ option.label }}</mat-option>
1414
}
1515
</mat-autocomplete>
1616
</mat-form-field>

packages/router/src/lib/debug/debug.page.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,17 @@ type CollectedRoute = {
2222
<div class="header-cell">Type</div>
2323
</div>
2424
<div class="table-body">
25-
@for (
26-
collectedRoute of collectedRoutes;
27-
track collectedRoute.filename
25+
@for ( collectedRoute of collectedRoutes; track collectedRoute.filename
2826
) {
29-
<div class="table-row">
30-
<div class="table-cell">{{ collectedRoute.path }}</div>
31-
<div class="table-cell" [title]="collectedRoute.filename">
32-
{{ collectedRoute.file }}
33-
</div>
34-
<div class="table-cell">
35-
{{ collectedRoute.isLayout ? 'Layout' : 'Page' }}
36-
</div>
27+
<div class="table-row">
28+
<div class="table-cell">{{ collectedRoute.path }}</div>
29+
<div class="table-cell" [title]="collectedRoute.filename">
30+
{{ collectedRoute.file }}
3731
</div>
32+
<div class="table-cell">
33+
{{ collectedRoute.isLayout ? 'Layout' : 'Page' }}
34+
</div>
35+
</div>
3836
}
3937
</div>
4038
</div>

packages/router/src/lib/server.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class ServerOnly {
9898
};
9999
}
100100
return throwError(
101-
() => ({}) as { html: string; outputs: ServerOutputs },
101+
() => ({} as { html: string; outputs: ServerOutputs }),
102102
);
103103
}),
104104
catchError((error: unknown) => {

packages/trpc/src/lib/client/shared-internal.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,25 @@ export type CreateTRPCClientBaseOptions<TRouter extends AnyRouter> =
9090
transformer?: 'You must set a transformer on the backend router';
9191
}
9292
: TRouter['_def']['_config']['transformer'] extends DataTransformerOptions
93-
? {
94-
/**
95-
* Data transformer
96-
*
97-
* You must use the same transformer on the backend and frontend
98-
* @link https://trpc.io/docs/data-transformers
99-
**/
100-
transformer: TRouter['_def']['_config']['transformer'] extends CombinedDataTransformer
101-
? DataTransformerOptions
102-
: TRouter['_def']['_config']['transformer'];
103-
}
104-
: {
105-
/**
106-
* Data transformer
107-
*
108-
* You must use the same transformer on the backend and frontend
109-
* @link https://trpc.io/docs/data-transformers
110-
**/
111-
transformer?:
112-
| /** @deprecated **/ ClientDataTransformerOptions
113-
| CombinedDataTransformer;
114-
};
93+
? {
94+
/**
95+
* Data transformer
96+
*
97+
* You must use the same transformer on the backend and frontend
98+
* @link https://trpc.io/docs/data-transformers
99+
**/
100+
transformer: TRouter['_def']['_config']['transformer'] extends CombinedDataTransformer
101+
? DataTransformerOptions
102+
: TRouter['_def']['_config']['transformer'];
103+
}
104+
: {
105+
/**
106+
* Data transformer
107+
*
108+
* You must use the same transformer on the backend and frontend
109+
* @link https://trpc.io/docs/data-transformers
110+
**/
111+
transformer?:
112+
| /** @deprecated **/ ClientDataTransformerOptions
113+
| CombinedDataTransformer;
114+
};

packages/trpc/src/lib/client/trpc-rxjs-proxy.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ type DecorateProcedure<
5050
query: Resolver<TProcedure>;
5151
}
5252
: TProcedure extends AnyMutationProcedure
53-
? {
54-
mutate: Resolver<TProcedure>;
55-
}
56-
: never;
53+
? {
54+
mutate: Resolver<TProcedure>;
55+
}
56+
: never;
5757

5858
// Removed subscription and using new type
5959
type DecoratedProcedureRecord<
@@ -66,8 +66,8 @@ type DecoratedProcedureRecord<
6666
TProcedures[TKey]
6767
>
6868
: TProcedures[TKey] extends AnyProcedure
69-
? DecorateProcedure<TProcedures[TKey], TRouter>
70-
: never;
69+
? DecorateProcedure<TProcedures[TKey], TRouter>
70+
: never;
7171
};
7272

7373
// Removed subscription and using new type

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

+7-13
Original file line numberDiff line numberDiff line change
@@ -8,50 +8,44 @@ describe('angularVitePlugin', () => {
88
});
99

1010
describe('isTestWatchMode', () => {
11-
it('should return false if vitest command not included in the command', () => {
12-
const result = isTestWatchMode('vite');
13-
14-
expect(result).toBeFalsy();
15-
});
16-
1711
it('should return false for vitest --run', () => {
18-
const result = isTestWatchMode('vitest', ['--run']);
12+
const result = isTestWatchMode(['--run']);
1913

2014
expect(result).toBeFalsy();
2115
});
2216

2317
it('should return true for vitest --no-run', () => {
24-
const result = isTestWatchMode('vitest', ['--no-run']);
18+
const result = isTestWatchMode(['--no-run']);
2519

2620
expect(result).toBeTruthy();
2721
});
2822

2923
it('should return true for vitest --watch', () => {
30-
const result = isTestWatchMode('vitest', ['--watch']);
24+
const result = isTestWatchMode(['--watch']);
3125

3226
expect(result).toBeTruthy();
3327
});
3428

3529
it('should return true for vitest watch', () => {
36-
const result = isTestWatchMode('vitest', ['watch']);
30+
const result = isTestWatchMode(['watch']);
3731

3832
expect(result).toBeTruthy();
3933
});
4034

4135
it('should return false for vitest --no-watch', () => {
42-
const result = isTestWatchMode('vitest', ['--no-watch']);
36+
const result = isTestWatchMode(['--no-watch']);
4337

4438
expect(result).toBeFalsy();
4539
});
4640

4741
it('should return false for vitest --watch=false', () => {
48-
const result = isTestWatchMode('vitest', ['--watch=false']);
42+
const result = isTestWatchMode(['--watch=false']);
4943

5044
expect(result).toBeFalsy();
5145
});
5246

5347
it('should return false for vitest --watch false', () => {
54-
const result = isTestWatchMode('vitest', ['--watch', 'false']);
48+
const result = isTestWatchMode(['--watch', 'false']);
5549

5650
expect(result).toBeFalsy();
5751
});

packages/vite-plugin-angular/src/lib/angular-vite-plugin.ts

+12-20
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,17 @@ export function angular(options?: PluginOptions): Plugin[] {
237237
configResolved(config) {
238238
resolvedConfig = config;
239239

240-
// set test watch mode
241-
// - vite override from vitest-angular
242-
// - @nx/vite executor set server.watch explicitly to undefined (watch)/null (watch=false)
243-
// - vite config for test.watch variable
244-
// - vitest watch mode detected from the command line
245-
testWatchMode =
246-
!(config.server.watch === null) ||
247-
config.test?.watch === true ||
248-
testWatchMode;
240+
if (isTest) {
241+
// set test watch mode
242+
// - vite override from vitest-angular
243+
// - @nx/vite executor set server.watch explicitly to undefined (watch)/null (watch=false)
244+
// - vite config for test.watch variable
245+
// - vitest watch mode detected from the command line
246+
testWatchMode =
247+
!(config.server.watch === null) ||
248+
config.test?.watch === true ||
249+
testWatchMode;
250+
}
249251
},
250252
configureServer(server) {
251253
viteServer = server;
@@ -1046,17 +1048,7 @@ function getFilenameFromPath(id: string): string {
10461048
* Checks for vitest run from the command line
10471049
* @returns boolean
10481050
*/
1049-
export function isTestWatchMode(
1050-
command = process.env['_'],
1051-
args = process.argv,
1052-
) {
1053-
const isVitestCommand = command?.includes('vitest');
1054-
1055-
// vitest command was not used
1056-
if (!isVitestCommand) {
1057-
return false;
1058-
}
1059-
1051+
export function isTestWatchMode(args = process.argv) {
10601052
// vitest --run
10611053
const hasRun = args.find((arg) => arg.includes('--run'));
10621054
if (hasRun) {

packages/vite-plugin-angular/src/lib/authoring/analog.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -504,8 +504,8 @@ function processAnalogScript(
504504
scope: hasExportKeyword
505505
? Scope.Protected
506506
: isVirtual
507-
? Scope.Private
508-
: undefined,
507+
? Scope.Private
508+
: undefined,
509509
});
510510
if (name !== ROUTE_META && !isVirtual) {
511511
targetConstructor.addStatements((writer) => {

packages/vite-plugin-angular/src/lib/component-resolvers.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ export class TemplateUrlsResolver {
102102

103103
const templateUrlPaths = getTemplateUrls(code).map(
104104
(url) =>
105-
`${url}|${normalizePath(resolve(dirname(id), url).replace(/\\/g, '/'))}`,
105+
`${url}|${normalizePath(
106+
resolve(dirname(id), url).replace(/\\/g, '/'),
107+
)}`,
106108
);
107109

108110
this.templateUrlsCache.set(id, { code, templateUrlPaths });

packages/vite-plugin-nitro/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export default async function render(_url: string, document: string) {
5252
const html = ReactDOMServer.renderToString(
5353
<React.StrictMode>
5454
<App />
55-
</React.StrictMode>
55+
</React.StrictMode>,
5656
);
5757
return document.replace('<!--app-html-->', html);
5858
}

0 commit comments

Comments
 (0)