Skip to content

Commit b9681c0

Browse files
committed
build: upgrade Vite to v8.0.16
Update vite to version 8.
1 parent 87c8318 commit b9681c0

21 files changed

Lines changed: 503 additions & 72 deletions

packages/angular/build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"semver": "7.8.4",
4242
"source-map-support": "0.5.21",
4343
"tinyglobby": "0.2.17",
44-
"vite": "7.3.5",
44+
"vite": "8.0.16",
4545
"watchpack": "2.5.2"
4646
},
4747
"optionalDependencies": {

packages/angular/build/src/builders/dev-server/vite/hmr.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
import type { ɵdestroyAngularServerApp as destroyAngularServerApp } from '@angular/ssr';
1010
import type { BuilderContext } from '@angular-devkit/architect';
1111
import { join } from 'node:path';
12-
import type { ViteDevServer } from 'vite';
12+
import type { ViteDevServer } from 'vite' with {
13+
'resolution-mode': 'import',
14+
};
1315
import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
1416
import { BuildOutputFileType } from '../internal';
1517
import type { NormalizedDevServerOptions } from '../options';

packages/angular/build/src/builders/dev-server/vite/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import type { BuilderContext } from '@angular-devkit/architect';
1010
import type { Plugin } from 'esbuild';
1111
import assert from 'node:assert';
1212
import { join } from 'node:path';
13-
import type { Connect, ViteDevServer } from 'vite';
13+
import type * as Vite from 'vite' with {
14+
'resolution-mode': 'import',
15+
};
1416
import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
1517
import { ServerSsrMode } from '../../../tools/vite/plugins';
1618
import { EsbuildLoaderOption, updateExternalMetadata } from '../../../tools/vite/utils';
@@ -58,7 +60,7 @@ export async function* serveWithVite(
5860
indexHtml?: (content: string) => Promise<string>;
5961
},
6062
extensions?: {
61-
middleware?: Connect.NextHandleFunction[];
63+
middleware?: Vite.Connect.NextHandleFunction[];
6264
buildPlugins?: Plugin[];
6365
},
6466
): AsyncIterableIterator<DevServerBuilderOutput> {
@@ -191,9 +193,9 @@ export async function* serveWithVite(
191193
// The index HTML path will be updated from the build results if provided by the builder
192194
let htmlIndexPath = 'index.html';
193195

194-
const { createServer, normalizePath } = await import('vite');
196+
const { createServer, normalizePath } = (await import('vite' as string)) as typeof Vite;
195197

196-
let server: ViteDevServer | undefined;
198+
let server: Vite.ViteDevServer | undefined;
197199
let serverUrl: URL | undefined;
198200
let hadError = false;
199201
const generatedFiles = new Map<string, OutputFileRecord>();

packages/angular/build/src/builders/dev-server/vite/server.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
import { readFile } from 'node:fs/promises';
1010
import { join } from 'node:path';
11-
import type { Connect, InlineConfig, SSROptions, ServerOptions } from 'vite';
11+
import type * as Vite from 'vite' with {
12+
'resolution-mode': 'import',
13+
};
1214
import type { ComponentStyleRecord } from '../../../tools/vite/middlewares';
1315
import {
1416
ServerSsrMode,
@@ -30,7 +32,7 @@ async function createServerConfig(
3032
ssrMode: ServerSsrMode,
3133
preTransformRequests: boolean,
3234
cacheDir: string,
33-
): Promise<ServerOptions> {
35+
): Promise<Vite.ServerOptions> {
3436
const proxy = await loadProxyConfiguration(
3537
serverOptions.workspaceRoot,
3638
serverOptions.proxyConfig,
@@ -47,7 +49,7 @@ async function createServerConfig(
4749
break;
4850
}
4951

50-
const server: ServerOptions = {
52+
const server: Vite.ServerOptions = {
5153
preTransformRequests,
5254
warmup: {
5355
ssrFiles,
@@ -101,7 +103,7 @@ function createSsrConfig(
101103
prebundleLoaderExtensions: EsbuildLoaderOption | undefined,
102104
thirdPartySourcemaps: boolean,
103105
define: ApplicationBuilderInternalOptions['define'],
104-
): SSROptions {
106+
): Vite.SSROptions {
105107
return {
106108
// Note: `true` and `/.*/` have different sematics. When true, the `external` option is ignored.
107109
noExternal: /.*/,
@@ -139,11 +141,11 @@ export async function setupServer(
139141
templateUpdates: Map<string, string>,
140142
prebundleLoaderExtensions: EsbuildLoaderOption | undefined,
141143
define: ApplicationBuilderInternalOptions['define'],
142-
extensionMiddleware?: Connect.NextHandleFunction[],
144+
extensionMiddleware?: Vite.Connect.NextHandleFunction[],
143145
indexHtmlTransformer?: (content: string) => Promise<string>,
144146
thirdPartySourcemaps = false,
145-
): Promise<InlineConfig> {
146-
const { normalizePath } = await import('vite');
147+
): Promise<Vite.InlineConfig> {
148+
const { normalizePath } = (await import('vite' as string)) as typeof Vite;
147149

148150
// Path will not exist on disk and only used to provide separate path for Vite requests
149151
const virtualProjectRoot = normalizePath(
@@ -161,13 +163,13 @@ export async function setupServer(
161163
externalMetadata.explicitBrowser.length === 0 && ssrMode === ServerSsrMode.NoSsr;
162164
const cacheDir = join(serverOptions.cacheOptions.path, serverOptions.buildTarget.project, 'vite');
163165

164-
const configuration: InlineConfig = {
166+
const configuration: Vite.InlineConfig = {
165167
configFile: false,
166168
envFile: false,
167169
cacheDir,
168170
root: virtualProjectRoot,
169171
publicDir: false,
170-
esbuild: false,
172+
oxc: false,
171173
mode: 'development',
172174
// We use custom as we do not rely on Vite's htmlFallbackMiddleware and indexHtmlMiddleware.
173175
appType: 'custom',

packages/angular/build/src/builders/unit-test/runners/vitest/executor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import type { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
1010
import assert from 'node:assert';
1111
import path from 'node:path';
12+
import type * as Vite from 'vite' with {
13+
'resolution-mode': 'import',
14+
};
1215
import type { Vitest } from 'vitest/node';
1316
import {
1417
DevServerExternalResultMetadata,
@@ -96,7 +99,7 @@ export class VitestExecutor implements TestExecutor {
9699

97100
async *execute(buildResult: FullResult | IncrementalResult): AsyncIterable<BuilderOutput> {
98101
this.debugLog(DebugLogLevel.Info, `Executing test run (kind: ${buildResult.kind}).`);
99-
this.normalizePath ??= (await import('vite')).normalizePath;
102+
this.normalizePath ??= ((await import('vite' as string)) as typeof Vite).normalizePath;
100103

101104
if (buildResult.kind === ResultKind.Full) {
102105
this.buildResultFiles.clear();

packages/angular/build/src/tools/vite/middlewares/assets-middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ import { createHash } from 'node:crypto';
1111
import { readFileSync } from 'node:fs';
1212
import type { ServerResponse } from 'node:http';
1313
import { extname } from 'node:path';
14-
import type { Connect, ViteDevServer } from 'vite';
14+
import type { Connect, ViteDevServer } from 'vite' with {
15+
'resolution-mode': 'import',
16+
};
1517
import { ResultFile } from '../../../builders/application/results';
1618
import { AngularMemoryOutputFiles, AngularOutputAssets, pathnameWithoutBasePath } from '../utils';
1719

packages/angular/build/src/tools/vite/middlewares/base-middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88

99
import type { IncomingMessage, ServerResponse } from 'node:http';
10-
import type { Connect } from 'vite';
10+
import type { Connect } from 'vite' with {
11+
'resolution-mode': 'import',
12+
};
1113
import { addLeadingSlash } from '../../../utils/url';
1214

1315
/**

packages/angular/build/src/tools/vite/middlewares/chrome-devtools-middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import assert from 'node:assert';
1010
import { randomUUID } from 'node:crypto';
1111
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
1212
import { join } from 'node:path';
13-
import type { Connect } from 'vite';
13+
import type { Connect } from 'vite' with {
14+
'resolution-mode': 'import',
15+
};
1416

1517
type DevToolsJson = {
1618
workspace: {

packages/angular/build/src/tools/vite/middlewares/component-middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import type { Connect, ViteDevServer } from 'vite';
9+
import type { Connect, ViteDevServer } from 'vite' with {
10+
'resolution-mode': 'import',
11+
};
1012
import { pathnameWithoutBasePath } from '../utils';
1113

1214
const ANGULAR_COMPONENT_PREFIX = '/@ng/component';

packages/angular/build/src/tools/vite/middlewares/headers-middleware.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
*/
88

99
import type { ServerResponse } from 'node:http';
10-
import type { Connect, ViteDevServer } from 'vite';
10+
import type { Connect, ViteDevServer } from 'vite' with {
11+
'resolution-mode': 'import',
12+
};
1113

1214
/**
1315
* Creates a middleware for adding custom headers.

0 commit comments

Comments
 (0)