mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
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.
This commit is contained in:
parent
eb8f1faa4c
commit
1cebc3a5e9
@ -12,7 +12,6 @@ import { BuilderContext } from '@angular-devkit/architect';
|
||||
import { BuilderOutput } from '@angular-devkit/architect';
|
||||
import type { ConfigOptions } from 'karma';
|
||||
import { Configuration } from 'webpack';
|
||||
import { DevServerBuildOutput } from '@angular-devkit/build-webpack';
|
||||
import type http from 'node:http';
|
||||
import { IndexHtmlTransform } from '@angular/build/private';
|
||||
import { json } from '@angular-devkit/core';
|
||||
@ -144,10 +143,14 @@ export interface DevServerBuilderOptions {
|
||||
}
|
||||
|
||||
// @public
|
||||
export type DevServerBuilderOutput = DevServerBuildOutput & {
|
||||
export interface DevServerBuilderOutput extends BuilderOutput {
|
||||
// (undocumented)
|
||||
address?: string;
|
||||
// (undocumented)
|
||||
baseUrl: string;
|
||||
stats: BuildEventStats;
|
||||
};
|
||||
// (undocumented)
|
||||
port?: number;
|
||||
}
|
||||
|
||||
// @public
|
||||
export function executeBrowserBuilder(options: BrowserBuilderOptions, context: BuilderContext, transforms?: {
|
||||
|
@ -311,6 +311,7 @@ LARGE_SPECS = {
|
||||
"size": "large",
|
||||
"flaky": True,
|
||||
"extra_deps": [
|
||||
"//packages/angular_devkit/build_webpack",
|
||||
"@npm//@types/http-proxy",
|
||||
"@npm//http-proxy",
|
||||
"@npm//puppeteer",
|
||||
|
@ -14,8 +14,8 @@ import { EMPTY, Observable, defer, switchMap } from 'rxjs';
|
||||
import type { ExecutionTransformer } from '../../transforms';
|
||||
import { checkPort } from '../../utils/check-port';
|
||||
import { normalizeOptions } from './options';
|
||||
import type { DevServerBuilderOutput } from './output';
|
||||
import type { Schema as DevServerBuilderOptions } from './schema';
|
||||
import type { DevServerBuilderOutput } from './webpack-server';
|
||||
|
||||
/**
|
||||
* A Builder that executes a development server based on the provided browser target option.
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import { createBuilder } from '@angular-devkit/architect';
|
||||
import { execute } from './builder';
|
||||
import { DevServerBuilderOutput } from './output';
|
||||
import { Schema as DevServerBuilderOptions } from './schema';
|
||||
import { DevServerBuilderOutput } from './webpack-server';
|
||||
|
||||
export { DevServerBuilderOptions, DevServerBuilderOutput, execute as executeDevServerBuilder };
|
||||
export default createBuilder<DevServerBuilderOptions, DevServerBuilderOutput>(execute);
|
||||
|
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import { BuilderOutput } from '@angular-devkit/architect';
|
||||
|
||||
/**
|
||||
* @experimental Direct usage of this type is considered experimental.
|
||||
*/
|
||||
export interface DevServerBuilderOutput extends BuilderOutput {
|
||||
baseUrl: string;
|
||||
port?: number;
|
||||
address?: string;
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
|
||||
import { Architect, BuilderRun } from '@angular-devkit/architect';
|
||||
import { DevServerBuilderOutput } from '@angular-devkit/build-angular';
|
||||
import { EmittedFiles } from '@angular-devkit/build-webpack';
|
||||
import { normalize, virtualFs } from '@angular-devkit/core';
|
||||
import { createArchitect, host } from '../../../testing/test-utils';
|
||||
|
||||
@ -54,7 +55,7 @@ describe('Dev Server Builder', () => {
|
||||
const output = (await run.result) as DevServerBuilderOutput;
|
||||
expect(output.success).toBe(true);
|
||||
const hasSourceMaps =
|
||||
output.emittedFiles && output.emittedFiles.some((f) => f.extension === '.map');
|
||||
output.emittedFiles && output.emittedFiles.some((f: EmittedFiles) => f.extension === '.map');
|
||||
expect(hasSourceMaps).toBe(false, `Expected emitted files not to contain '.map' files.`);
|
||||
});
|
||||
|
||||
|
@ -33,7 +33,7 @@ import { getIndexOutputFile } from '../../utils/webpack-browser-config';
|
||||
import { buildEsbuildBrowser } from '../browser-esbuild';
|
||||
import { Schema as BrowserBuilderOptions } from '../browser-esbuild/schema';
|
||||
import type { NormalizedDevServerOptions } from './options';
|
||||
import type { DevServerBuilderOutput } from './webpack-server';
|
||||
import type { DevServerBuilderOutput } from './output';
|
||||
|
||||
interface OutputFileRecord {
|
||||
contents: Uint8Array;
|
||||
|
Loading…
x
Reference in New Issue
Block a user