refactor(@angular-devkit/build-angular): remove unused host parameter from typescript webpack methods

This commit is contained in:
Charles Lyding 2019-03-13 13:10:05 -04:00 committed by vikerman
parent 8644608987
commit ebf90b3d6a
6 changed files with 15 additions and 26 deletions

View File

@ -7,8 +7,6 @@
*/ */
// tslint:disable // tslint:disable
// TODO: cleanup this file, it's copied as is from Angular CLI. // 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 * as path from 'path';
import { import {
AngularCompilerPlugin, AngularCompilerPlugin,
@ -23,7 +21,6 @@ import { WebpackConfigOptions } from '../build-options';
function _createAotPlugin( function _createAotPlugin(
wco: WebpackConfigOptions, wco: WebpackConfigOptions,
options: any, options: any,
_host: virtualFs.Host<Stats>,
useMain = true, useMain = true,
extract = false, extract = false,
) { ) {
@ -83,20 +80,16 @@ function _createAotPlugin(
return new AngularCompilerPlugin(pluginOptions); return new AngularCompilerPlugin(pluginOptions);
} }
export function getNonAotConfig(wco: WebpackConfigOptions, host: virtualFs.Host<Stats>) { export function getNonAotConfig(wco: WebpackConfigOptions) {
const { tsConfigPath } = wco; const { tsConfigPath } = wco;
return { return {
module: { rules: [{ test: /\.tsx?$/, loader: NgToolsLoader }] }, module: { rules: [{ test: /\.tsx?$/, loader: NgToolsLoader }] },
plugins: [_createAotPlugin(wco, { tsConfigPath, skipCodeGeneration: true }, host)] plugins: [_createAotPlugin(wco, { tsConfigPath, skipCodeGeneration: true })]
}; };
} }
export function getAotConfig( export function getAotConfig(wco: WebpackConfigOptions, extract = false) {
wco: WebpackConfigOptions,
host: virtualFs.Host<Stats>,
extract = false
) {
const { tsConfigPath, buildOptions } = wco; const { tsConfigPath, buildOptions } = wco;
const loaders: any[] = [NgToolsLoader]; const loaders: any[] = [NgToolsLoader];
@ -111,6 +104,6 @@ export function getAotConfig(
return { return {
module: { rules: [{ test, use: loaders }] }, module: { rules: [{ test, use: loaders }] },
plugins: [_createAotPlugin(wco, { tsConfigPath }, host, true, extract)] plugins: [_createAotPlugin(wco, { tsConfigPath }, true, extract)]
}; };
} }

View File

@ -149,8 +149,8 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
if (wco.buildOptions.main || wco.buildOptions.polyfills) { if (wco.buildOptions.main || wco.buildOptions.polyfills) {
const typescriptConfigPartial = wco.buildOptions.aot const typescriptConfigPartial = wco.buildOptions.aot
? getAotConfig(wco, host) ? getAotConfig(wco)
: getNonAotConfig(wco, host); : getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial); webpackConfigs.push(typescriptConfigPartial);
} }

View File

@ -95,7 +95,6 @@ export function createBrowserLoggingCallback(
export function buildWebpackConfig( export function buildWebpackConfig(
root: Path, root: Path,
projectRoot: Path, projectRoot: Path,
host: virtualFs.Host<fs.Stats>,
options: NormalizedBrowserBuilderSchema, options: NormalizedBrowserBuilderSchema,
logger: logging.LoggerApi, logger: logging.LoggerApi,
): webpack.Configuration { ): webpack.Configuration {
@ -135,8 +134,8 @@ export function buildWebpackConfig(
if (wco.buildOptions.main || wco.buildOptions.polyfills) { if (wco.buildOptions.main || wco.buildOptions.polyfills) {
const typescriptConfigPartial = wco.buildOptions.aot const typescriptConfigPartial = wco.buildOptions.aot
? getAotConfig(wco, host) ? getAotConfig(wco)
: getNonAotConfig(wco, host); : getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial); webpackConfigs.push(typescriptConfigPartial);
} }
@ -174,7 +173,7 @@ export async function buildBrowserWebpackConfigFromWorkspace(
options, options,
); );
return buildWebpackConfig(workspace.root, projectRoot, host, normalizedOptions, logger); return buildWebpackConfig(workspace.root, projectRoot, normalizedOptions, logger);
} }

View File

@ -12,8 +12,7 @@ import {
BuilderContext, BuilderContext,
} from '@angular-devkit/architect'; } from '@angular-devkit/architect';
import { LoggingCallback, WebpackBuilder } from '@angular-devkit/build-webpack'; import { LoggingCallback, WebpackBuilder } from '@angular-devkit/build-webpack';
import { Path, getSystemPath, normalize, resolve, virtualFs } from '@angular-devkit/core'; import { Path, getSystemPath, normalize, resolve } from '@angular-devkit/core';
import * as fs from 'fs';
import * as path from 'path'; import * as path from 'path';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { concatMap, map } from 'rxjs/operators'; import { concatMap, map } from 'rxjs/operators';
@ -114,8 +113,6 @@ export class ExtractI18nBuilder implements Builder<ExtractI18nBuilderOptions> {
) { ) {
let wco: WebpackConfigOptions; 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 tsConfigPath = getSystemPath(normalize(resolve(root, normalize(options.tsConfig))));
const tsConfig = readTsconfig(tsConfigPath); const tsConfig = readTsconfig(tsConfigPath);
@ -134,7 +131,7 @@ export class ExtractI18nBuilder implements Builder<ExtractI18nBuilderOptions> {
// We don't need to write to disk. // We don't need to write to disk.
{ plugins: [new InMemoryOutputPlugin()] }, { plugins: [new InMemoryOutputPlugin()] },
getCommonConfig(wco), getCommonConfig(wco),
getAotConfig(wco, host, true), getAotConfig(wco, true),
getStylesConfig(wco), getStylesConfig(wco),
getStatsConfig(wco), getStatsConfig(wco),
]; ];

View File

@ -156,7 +156,7 @@ export class KarmaBuilder implements Builder<KarmaBuilderSchema> {
const webpackConfigs: {}[] = [ const webpackConfigs: {}[] = [
getCommonConfig(wco), getCommonConfig(wco),
getStylesConfig(wco), getStylesConfig(wco),
getNonAotConfig(wco, host), getNonAotConfig(wco),
getTestConfig(wco), getTestConfig(wco),
]; ];

View File

@ -67,7 +67,7 @@ export class ServerBuilder implements Builder<BuildWebpackServerSchema> {
} }
buildWebpackConfig(root: Path, projectRoot: Path, buildWebpackConfig(root: Path, projectRoot: Path,
host: virtualFs.Host<Stats>, _host: virtualFs.Host<Stats>,
options: NormalizedServerBuilderServerSchema) { options: NormalizedServerBuilderServerSchema) {
let wco: WebpackConfigOptions; let wco: WebpackConfigOptions;
@ -115,8 +115,8 @@ export class ServerBuilder implements Builder<BuildWebpackServerSchema> {
if (wco.buildOptions.main || wco.buildOptions.polyfills) { if (wco.buildOptions.main || wco.buildOptions.polyfills) {
const typescriptConfigPartial = wco.buildOptions.aot const typescriptConfigPartial = wco.buildOptions.aot
? getAotConfig(wco, host) ? getAotConfig(wco)
: getNonAotConfig(wco, host); : getNonAotConfig(wco);
webpackConfigs.push(typescriptConfigPartial); webpackConfigs.push(typescriptConfigPartial);
} }