Skip to content

Commit 655626c

Browse files
Alan Agiusmgechev
Alan Agius
authored andcommitted
refactor(@ngtools/webpack): move interfaces to separate file
This is to avoid circular imports
1 parent f84abfc commit 655626c

File tree

2 files changed

+75
-56
lines changed

2 files changed

+75
-56
lines changed

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 8 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,14 @@ import * as path from 'path';
3636
import * as ts from 'typescript';
3737
import { Compiler, compilation } from 'webpack';
3838
import { time, timeEnd } from './benchmark';
39-
import { WebpackCompilerHost, workaroundResolve } from './compiler_host';
39+
import { WebpackCompilerHost } from './compiler_host';
4040
import { resolveEntryModuleFromMain } from './entry_resolver';
4141
import { DiagnosticMode, gatherDiagnostics, hasErrors } from './gather_diagnostics';
42+
import {
43+
AngularCompilerPluginOptions,
44+
ContextElementDependencyConstructor,
45+
PLATFORM,
46+
} from './interfaces';
4247
import { LazyRouteMap, findLazyRoutes } from './lazy_routes';
4348
import { TypeScriptPathsPlugin } from './paths-plugin';
4449
import { WebpackResourceLoader } from './resource_loader';
@@ -63,6 +68,7 @@ import {
6368
MESSAGE_KIND,
6469
UpdateMessage,
6570
} from './type_checker_messages';
71+
import { workaroundResolve } from './utils';
6672
import {
6773
VirtualFileSystemDecorator,
6874
VirtualWatchFileSystemDecorator,
@@ -76,61 +82,6 @@ import { WebpackInputHost } from './webpack-input-host';
7682

7783
const treeKill = require('tree-kill');
7884

79-
export interface ContextElementDependency { }
80-
81-
export interface ContextElementDependencyConstructor {
82-
new(modulePath: string, name: string): ContextElementDependency;
83-
}
84-
85-
/**
86-
* Option Constants
87-
*/
88-
export interface AngularCompilerPluginOptions {
89-
sourceMap?: boolean;
90-
tsConfigPath: string;
91-
basePath?: string;
92-
entryModule?: string;
93-
mainPath?: string;
94-
skipCodeGeneration?: boolean;
95-
hostReplacementPaths?: { [path: string]: string } | ((path: string) => string);
96-
forkTypeChecker?: boolean;
97-
i18nInFile?: string;
98-
i18nInFormat?: string;
99-
i18nOutFile?: string;
100-
i18nOutFormat?: string;
101-
locale?: string;
102-
missingTranslation?: string;
103-
platform?: PLATFORM;
104-
nameLazyFiles?: boolean;
105-
logger?: logging.Logger;
106-
directTemplateLoading?: boolean;
107-
// When using the loadChildren string syntax, @ngtools/webpack must query @angular/compiler-cli
108-
// via a private API to know which lazy routes exist. This increases build and rebuild time.
109-
// When using Ivy, the string syntax is not supported at all. Thus we shouldn't attempt that.
110-
// This option is also used for when the compilation doesn't need this sort of processing at all.
111-
discoverLazyRoutes?: boolean;
112-
importFactories?: boolean;
113-
114-
// added to the list of lazy routes
115-
additionalLazyModules?: { [module: string]: string };
116-
additionalLazyModuleResources?: string[];
117-
118-
// The ContextElementDependency of correct Webpack compilation.
119-
// This is needed when there are multiple Webpack installs.
120-
contextElementDependencyConstructor?: ContextElementDependencyConstructor;
121-
122-
// Use tsconfig to include path globs.
123-
compilerOptions?: ts.CompilerOptions;
124-
125-
host?: virtualFs.Host<fs.Stats>;
126-
platformTransformers?: ts.TransformerFactory<ts.SourceFile>[];
127-
}
128-
129-
export enum PLATFORM {
130-
Browser,
131-
Server,
132-
}
133-
13485
export class AngularCompilerPlugin {
13586
private _options: AngularCompilerPluginOptions;
13687

@@ -701,6 +652,7 @@ export class AngularCompilerPlugin {
701652
host,
702653
true,
703654
this._options.directTemplateLoading,
655+
this._platform,
704656
);
705657

706658
// Create and set a new WebpackResourceLoader in AOT
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. 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 { logging, virtualFs } from '@angular-devkit/core';
10+
import * as fs from 'fs';
11+
import * as ts from 'typescript';
12+
13+
export enum PLATFORM {
14+
Browser,
15+
Server,
16+
}
17+
18+
export interface ContextElementDependency { }
19+
20+
export interface ContextElementDependencyConstructor {
21+
new(modulePath: string, name: string): ContextElementDependency;
22+
}
23+
24+
/**
25+
* Option Constants
26+
*/
27+
export interface AngularCompilerPluginOptions {
28+
sourceMap?: boolean;
29+
tsConfigPath: string;
30+
basePath?: string;
31+
entryModule?: string;
32+
mainPath?: string;
33+
skipCodeGeneration?: boolean;
34+
hostReplacementPaths?: { [path: string]: string } | ((path: string) => string);
35+
forkTypeChecker?: boolean;
36+
i18nInFile?: string;
37+
i18nInFormat?: string;
38+
i18nOutFile?: string;
39+
i18nOutFormat?: string;
40+
locale?: string;
41+
missingTranslation?: string;
42+
platform?: PLATFORM;
43+
nameLazyFiles?: boolean;
44+
logger?: logging.Logger;
45+
directTemplateLoading?: boolean;
46+
47+
// When using the loadChildren string syntax, @ngtools/webpack must query @angular/compiler-cli
48+
// via a private API to know which lazy routes exist. This increases build and rebuild time.
49+
// When using Ivy, the string syntax is not supported at all. Thus we shouldn't attempt that.
50+
// This option is also used for when the compilation doesn't need this sort of processing at all.
51+
discoverLazyRoutes?: boolean;
52+
importFactories?: boolean;
53+
54+
// added to the list of lazy routes
55+
additionalLazyModules?: { [module: string]: string };
56+
additionalLazyModuleResources?: string[];
57+
58+
// The ContextElementDependency of correct Webpack compilation.
59+
// This is needed when there are multiple Webpack installs.
60+
contextElementDependencyConstructor?: ContextElementDependencyConstructor;
61+
62+
// Use tsconfig to include path globs.
63+
compilerOptions?: ts.CompilerOptions;
64+
65+
host?: virtualFs.Host<fs.Stats>;
66+
platformTransformers?: ts.TransformerFactory<ts.SourceFile>[];
67+
}

0 commit comments

Comments
 (0)