mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-19 04:26:01 +08:00
refactor(@angular-devkit/build-angular): remove unused host parameter from typescript webpack methods
This commit is contained in:
parent
8644608987
commit
ebf90b3d6a
@ -7,8 +7,6 @@
|
||||
*/
|
||||
// tslint:disable
|
||||
// TODO: cleanup this file, it's copied as is from Angular CLI.
|
||||
import { virtualFs } from '@angular-devkit/core';
|
||||
import { Stats } from 'fs';
|
||||
import * as path from 'path';
|
||||
import {
|
||||
AngularCompilerPlugin,
|
||||
@ -23,7 +21,6 @@ import { WebpackConfigOptions } from '../build-options';
|
||||
function _createAotPlugin(
|
||||
wco: WebpackConfigOptions,
|
||||
options: any,
|
||||
_host: virtualFs.Host<Stats>,
|
||||
useMain = true,
|
||||
extract = false,
|
||||
) {
|
||||
@ -83,20 +80,16 @@ function _createAotPlugin(
|
||||
return new AngularCompilerPlugin(pluginOptions);
|
||||
}
|
||||
|
||||
export function getNonAotConfig(wco: WebpackConfigOptions, host: virtualFs.Host<Stats>) {
|
||||
export function getNonAotConfig(wco: WebpackConfigOptions) {
|
||||
const { tsConfigPath } = wco;
|
||||
|
||||
return {
|
||||
module: { rules: [{ test: /\.tsx?$/, loader: NgToolsLoader }] },
|
||||
plugins: [_createAotPlugin(wco, { tsConfigPath, skipCodeGeneration: true }, host)]
|
||||
plugins: [_createAotPlugin(wco, { tsConfigPath, skipCodeGeneration: true })]
|
||||
};
|
||||
}
|
||||
|
||||
export function getAotConfig(
|
||||
wco: WebpackConfigOptions,
|
||||
host: virtualFs.Host<Stats>,
|
||||
extract = false
|
||||
) {
|
||||
export function getAotConfig(wco: WebpackConfigOptions, extract = false) {
|
||||
const { tsConfigPath, buildOptions } = wco;
|
||||
|
||||
const loaders: any[] = [NgToolsLoader];
|
||||
@ -111,6 +104,6 @@ export function getAotConfig(
|
||||
|
||||
return {
|
||||
module: { rules: [{ test, use: loaders }] },
|
||||
plugins: [_createAotPlugin(wco, { tsConfigPath }, host, true, extract)]
|
||||
plugins: [_createAotPlugin(wco, { tsConfigPath }, true, extract)]
|
||||
};
|
||||
}
|
||||
|
@ -149,8 +149,8 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
|
||||
|
||||
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
|
||||
const typescriptConfigPartial = wco.buildOptions.aot
|
||||
? getAotConfig(wco, host)
|
||||
: getNonAotConfig(wco, host);
|
||||
? getAotConfig(wco)
|
||||
: getNonAotConfig(wco);
|
||||
webpackConfigs.push(typescriptConfigPartial);
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,6 @@ export function createBrowserLoggingCallback(
|
||||
export function buildWebpackConfig(
|
||||
root: Path,
|
||||
projectRoot: Path,
|
||||
host: virtualFs.Host<fs.Stats>,
|
||||
options: NormalizedBrowserBuilderSchema,
|
||||
logger: logging.LoggerApi,
|
||||
): webpack.Configuration {
|
||||
@ -135,8 +134,8 @@ export function buildWebpackConfig(
|
||||
|
||||
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
|
||||
const typescriptConfigPartial = wco.buildOptions.aot
|
||||
? getAotConfig(wco, host)
|
||||
: getNonAotConfig(wco, host);
|
||||
? getAotConfig(wco)
|
||||
: getNonAotConfig(wco);
|
||||
webpackConfigs.push(typescriptConfigPartial);
|
||||
}
|
||||
|
||||
@ -174,7 +173,7 @@ export async function buildBrowserWebpackConfigFromWorkspace(
|
||||
options,
|
||||
);
|
||||
|
||||
return buildWebpackConfig(workspace.root, projectRoot, host, normalizedOptions, logger);
|
||||
return buildWebpackConfig(workspace.root, projectRoot, normalizedOptions, logger);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,8 +12,7 @@ import {
|
||||
BuilderContext,
|
||||
} from '@angular-devkit/architect';
|
||||
import { LoggingCallback, WebpackBuilder } from '@angular-devkit/build-webpack';
|
||||
import { Path, getSystemPath, normalize, resolve, virtualFs } from '@angular-devkit/core';
|
||||
import * as fs from 'fs';
|
||||
import { Path, getSystemPath, normalize, resolve } from '@angular-devkit/core';
|
||||
import * as path from 'path';
|
||||
import { Observable } from 'rxjs';
|
||||
import { concatMap, map } from 'rxjs/operators';
|
||||
@ -114,8 +113,6 @@ export class ExtractI18nBuilder implements Builder<ExtractI18nBuilderOptions> {
|
||||
) {
|
||||
let wco: WebpackConfigOptions;
|
||||
|
||||
const host = new virtualFs.AliasHost(this.context.host as virtualFs.Host<fs.Stats>);
|
||||
|
||||
const tsConfigPath = getSystemPath(normalize(resolve(root, normalize(options.tsConfig))));
|
||||
const tsConfig = readTsconfig(tsConfigPath);
|
||||
|
||||
@ -134,7 +131,7 @@ export class ExtractI18nBuilder implements Builder<ExtractI18nBuilderOptions> {
|
||||
// We don't need to write to disk.
|
||||
{ plugins: [new InMemoryOutputPlugin()] },
|
||||
getCommonConfig(wco),
|
||||
getAotConfig(wco, host, true),
|
||||
getAotConfig(wco, true),
|
||||
getStylesConfig(wco),
|
||||
getStatsConfig(wco),
|
||||
];
|
||||
|
@ -156,7 +156,7 @@ export class KarmaBuilder implements Builder<KarmaBuilderSchema> {
|
||||
const webpackConfigs: {}[] = [
|
||||
getCommonConfig(wco),
|
||||
getStylesConfig(wco),
|
||||
getNonAotConfig(wco, host),
|
||||
getNonAotConfig(wco),
|
||||
getTestConfig(wco),
|
||||
];
|
||||
|
||||
|
@ -67,7 +67,7 @@ export class ServerBuilder implements Builder<BuildWebpackServerSchema> {
|
||||
}
|
||||
|
||||
buildWebpackConfig(root: Path, projectRoot: Path,
|
||||
host: virtualFs.Host<Stats>,
|
||||
_host: virtualFs.Host<Stats>,
|
||||
options: NormalizedServerBuilderServerSchema) {
|
||||
let wco: WebpackConfigOptions;
|
||||
|
||||
@ -115,8 +115,8 @@ export class ServerBuilder implements Builder<BuildWebpackServerSchema> {
|
||||
|
||||
if (wco.buildOptions.main || wco.buildOptions.polyfills) {
|
||||
const typescriptConfigPartial = wco.buildOptions.aot
|
||||
? getAotConfig(wco, host)
|
||||
: getNonAotConfig(wco, host);
|
||||
? getAotConfig(wco)
|
||||
: getNonAotConfig(wco);
|
||||
webpackConfigs.push(typescriptConfigPartial);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user