Skip to content

Commit 1cebc3a

Browse files
committed
refactor(@angular-devkit/build-angular): use dev-server implementation neutral builder output result interface
The dev-server builder will now only provide an interface with typed fields for the combined set of common elements for the Webpack and Vite development server implementations. Any additional builder specific runtime fields will still be present and accessible.
1 parent eb8f1fa commit 1cebc3a

File tree

7 files changed

+31
-8
lines changed

7 files changed

+31
-8
lines changed

goldens/public-api/angular_devkit/build_angular/index.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { BuilderContext } from '@angular-devkit/architect';
1212
import { BuilderOutput } from '@angular-devkit/architect';
1313
import type { ConfigOptions } from 'karma';
1414
import { Configuration } from 'webpack';
15-
import { DevServerBuildOutput } from '@angular-devkit/build-webpack';
1615
import type http from 'node:http';
1716
import { IndexHtmlTransform } from '@angular/build/private';
1817
import { json } from '@angular-devkit/core';
@@ -144,10 +143,14 @@ export interface DevServerBuilderOptions {
144143
}
145144

146145
// @public
147-
export type DevServerBuilderOutput = DevServerBuildOutput & {
146+
export interface DevServerBuilderOutput extends BuilderOutput {
147+
// (undocumented)
148+
address?: string;
149+
// (undocumented)
148150
baseUrl: string;
149-
stats: BuildEventStats;
150-
};
151+
// (undocumented)
152+
port?: number;
153+
}
151154

152155
// @public
153156
export function executeBrowserBuilder(options: BrowserBuilderOptions, context: BuilderContext, transforms?: {

packages/angular_devkit/build_angular/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ LARGE_SPECS = {
311311
"size": "large",
312312
"flaky": True,
313313
"extra_deps": [
314+
"//packages/angular_devkit/build_webpack",
314315
"@npm//@types/http-proxy",
315316
"@npm//http-proxy",
316317
"@npm//puppeteer",

packages/angular_devkit/build_angular/src/builders/dev-server/builder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { EMPTY, Observable, defer, switchMap } from 'rxjs';
1414
import type { ExecutionTransformer } from '../../transforms';
1515
import { checkPort } from '../../utils/check-port';
1616
import { normalizeOptions } from './options';
17+
import type { DevServerBuilderOutput } from './output';
1718
import type { Schema as DevServerBuilderOptions } from './schema';
18-
import type { DevServerBuilderOutput } from './webpack-server';
1919

2020
/**
2121
* A Builder that executes a development server based on the provided browser target option.

packages/angular_devkit/build_angular/src/builders/dev-server/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import { createBuilder } from '@angular-devkit/architect';
1010
import { execute } from './builder';
11+
import { DevServerBuilderOutput } from './output';
1112
import { Schema as DevServerBuilderOptions } from './schema';
12-
import { DevServerBuilderOutput } from './webpack-server';
1313

1414
export { DevServerBuilderOptions, DevServerBuilderOutput, execute as executeDevServerBuilder };
1515
export default createBuilder<DevServerBuilderOptions, DevServerBuilderOutput>(execute);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import { BuilderOutput } from '@angular-devkit/architect';
10+
11+
/**
12+
* @experimental Direct usage of this type is considered experimental.
13+
*/
14+
export interface DevServerBuilderOutput extends BuilderOutput {
15+
baseUrl: string;
16+
port?: number;
17+
address?: string;
18+
}

packages/angular_devkit/build_angular/src/builders/dev-server/specs/works_spec.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import { Architect, BuilderRun } from '@angular-devkit/architect';
1010
import { DevServerBuilderOutput } from '@angular-devkit/build-angular';
11+
import { EmittedFiles } from '@angular-devkit/build-webpack';
1112
import { normalize, virtualFs } from '@angular-devkit/core';
1213
import { createArchitect, host } from '../../../testing/test-utils';
1314

@@ -54,7 +55,7 @@ describe('Dev Server Builder', () => {
5455
const output = (await run.result) as DevServerBuilderOutput;
5556
expect(output.success).toBe(true);
5657
const hasSourceMaps =
57-
output.emittedFiles && output.emittedFiles.some((f) => f.extension === '.map');
58+
output.emittedFiles && output.emittedFiles.some((f: EmittedFiles) => f.extension === '.map');
5859
expect(hasSourceMaps).toBe(false, `Expected emitted files not to contain '.map' files.`);
5960
});
6061

packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { getIndexOutputFile } from '../../utils/webpack-browser-config';
3333
import { buildEsbuildBrowser } from '../browser-esbuild';
3434
import { Schema as BrowserBuilderOptions } from '../browser-esbuild/schema';
3535
import type { NormalizedDevServerOptions } from './options';
36-
import type { DevServerBuilderOutput } from './webpack-server';
36+
import type { DevServerBuilderOutput } from './output';
3737

3838
interface OutputFileRecord {
3939
contents: Uint8Array;

0 commit comments

Comments
 (0)