Skip to content

Commit 3034019

Browse files
clydinhansl
authored andcommitted
build: update webpack types
1 parent 6d68703 commit 3034019

File tree

9 files changed

+91
-91
lines changed

9 files changed

+91
-91
lines changed

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
"@types/request": "^2.47.1",
8181
"@types/semver": "^5.5.0",
8282
"@types/source-map": "0.5.2",
83-
"@types/webpack": "^4.4.0",
84-
"@types/webpack-dev-server": "^2.9.4",
85-
"@types/webpack-sources": "^0.1.4",
83+
"@types/webpack": "^4.4.11",
84+
"@types/webpack-dev-server": "^3.1.0",
85+
"@types/webpack-sources": "^0.1.5",
8686
"common-tags": "^1.8.0",
8787
"conventional-changelog": "^1.1.0",
8888
"conventional-commits-parser": "^3.0.0",
@@ -107,8 +107,6 @@
107107
"tslint-sonarts": "^1.7.0"
108108
},
109109
"resolutions": {
110-
"@types/webpack": "4.4.0",
111-
"@types/webpack-dev-server": "2.9.4",
112110
"rxjs": "~6.2.0"
113111
}
114112
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
210210
index: `${servePath}/${path.basename(browserOptions.index)}`,
211211
disableDotRule: true,
212212
htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'],
213-
},
213+
} as WebpackDevServer.HistoryApiFallbackConfig,
214214
stats: false,
215215
compress: browserOptions.optimization,
216216
watchOptions: {

packages/angular_devkit/build_angular/src/utils/webpack-file-system-host-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { FileDoesNotExistException, JsonObject, normalize, virtualFs } from '@angular-devkit/core';
9-
import { Callback, InputFileSystem } from '@ngtools/webpack/src/webpack';
9+
import { Callback } from '@ngtools/webpack/src/webpack';
1010
import { Stats } from 'fs';
1111
import { Observable, of } from 'rxjs';
1212
import { map, mergeMap, switchMap } from 'rxjs/operators';
1313

1414

15-
export class WebpackFileSystemHostAdapter implements InputFileSystem {
15+
export class WebpackFileSystemHostAdapter {
1616
protected _syncHost: virtualFs.SyncDelegateHost<Stats> | null = null;
1717

1818
constructor(protected _host: virtualFs.Host<Stats>) {}

packages/angular_devkit/build_webpack/src/webpack-dev-server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class WebpackDevServerBuilder implements Builder<WebpackDevServerBuilderS
4949
devServerConfig.port = devServerConfig.port || 8080;
5050

5151
if (devServerConfig.stats) {
52-
webpackConfig.stats = devServerConfig.stats;
52+
webpackConfig.stats = devServerConfig.stats as webpack.Stats.ToStringOptionsObject;
5353
}
5454
// Disable stats reporting by the devserver, we have our own logger.
5555
devServerConfig.stats = false;

packages/ngtools/webpack/src/angular_compiler_plugin.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import {
5252
} from './virtual_file_system_decorator';
5353
import {
5454
Callback,
55-
InputFileSystem,
5655
NodeWatchFileSystemInterface,
5756
NormalModuleFactoryRequest,
5857
} from './webpack';
@@ -583,7 +582,6 @@ export class AngularCompilerPlugin {
583582
compiler.hooks.environment.tap('angular-compiler', () => {
584583
// The webpack types currently do not include these
585584
const compilerWithFileSystems = compiler as Compiler & {
586-
inputFileSystem: InputFileSystem,
587585
watchFileSystem: NodeWatchFileSystemInterface,
588586
};
589587

packages/ngtools/webpack/src/virtual_file_system_decorator.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
*/
88
import { Path, getSystemPath, normalize } from '@angular-devkit/core';
99
import { Stats } from 'fs';
10+
import { InputFileSystem } from 'webpack';
1011
import { WebpackCompilerHost } from './compiler_host';
11-
import { Callback, InputFileSystem, NodeWatchFileSystemInterface } from './webpack';
12+
import { Callback, NodeWatchFileSystemInterface } from './webpack';
1213

1314
export const NodeWatchFileSystem: NodeWatchFileSystemInterface = require(
1415
'webpack/lib/node/NodeWatchFileSystem');
1516

17+
// NOTE: @types/webpack InputFileSystem is missing some methods
1618
export class VirtualFileSystemDecorator implements InputFileSystem {
1719
constructor(
1820
private _inputFileSystem: InputFileSystem,
@@ -39,33 +41,37 @@ export class VirtualFileSystemDecorator implements InputFileSystem {
3941
return this._webpackCompilerHost.getNgFactoryPaths();
4042
}
4143

42-
stat(path: string, callback: Callback<Stats>): void {
44+
stat(path: string, callback: (err: Error, stats: Stats) => void): void {
4345
const result = this._statSync(path);
4446
if (result) {
45-
callback(null, result);
47+
// tslint:disable-next-line:no-any
48+
callback(null as any, result);
4649
} else {
4750
this._inputFileSystem.stat(path, callback);
4851
}
4952
}
5053

5154
readdir(path: string, callback: Callback<string[]>): void {
52-
this._inputFileSystem.readdir(path, callback);
55+
// tslint:disable-next-line:no-any
56+
(this._inputFileSystem as any).readdir(path, callback);
5357
}
5458

55-
readFile(path: string, callback: Callback<Buffer>): void {
59+
readFile(path: string, callback: (err: Error, contents: Buffer) => void): void {
5660
const result = this._readFileSync(path);
5761
if (result) {
58-
callback(null, result);
62+
// tslint:disable-next-line:no-any
63+
callback(null as any, result);
5964
} else {
6065
this._inputFileSystem.readFile(path, callback);
6166
}
6267
}
6368

6469
readJson(path: string, callback: Callback<{}>): void {
65-
this._inputFileSystem.readJson(path, callback);
70+
// tslint:disable-next-line:no-any
71+
(this._inputFileSystem as any).readJson(path, callback);
6672
}
6773

68-
readlink(path: string, callback: Callback<string>): void {
74+
readlink(path: string, callback: (err: Error, linkString: string) => void): void {
6975
this._inputFileSystem.readlink(path, callback);
7076
}
7177

@@ -76,7 +82,8 @@ export class VirtualFileSystemDecorator implements InputFileSystem {
7682
}
7783

7884
readdirSync(path: string): string[] {
79-
return this._inputFileSystem.readdirSync(path);
85+
// tslint:disable-next-line:no-any
86+
return (this._inputFileSystem as any).readdirSync(path);
8087
}
8188

8289
readFileSync(path: string): Buffer {
@@ -86,7 +93,8 @@ export class VirtualFileSystemDecorator implements InputFileSystem {
8693
}
8794

8895
readJsonSync(path: string): string {
89-
return this._inputFileSystem.readJsonSync(path);
96+
// tslint:disable-next-line:no-any
97+
return (this._inputFileSystem as any).readJsonSync(path);
9098
}
9199

92100
readlinkSync(path: string): string {
@@ -100,7 +108,8 @@ export class VirtualFileSystemDecorator implements InputFileSystem {
100108
changes.forEach((fileName: string) => this._webpackCompilerHost.invalidate(fileName));
101109
}
102110
if (this._inputFileSystem.purge) {
103-
this._inputFileSystem.purge(changes);
111+
// tslint:disable-next-line:no-any
112+
(this._inputFileSystem as any).purge(changes);
104113
}
105114
}
106115
}

packages/ngtools/webpack/src/webpack-input-host.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Path, PathFragment, fragment, getSystemPath, virtualFs } from '@angular
99
import { Stats } from 'fs';
1010
import { Observable, throwError } from 'rxjs';
1111
import { map } from 'rxjs/operators';
12-
import { InputFileSystem } from './webpack';
12+
import { InputFileSystem } from 'webpack';
1313

1414
// Host is used instead of ReadonlyHost due to most decorators only supporting Hosts
1515
export class WebpackInputHost implements virtualFs.Host<Stats> {
@@ -51,7 +51,8 @@ export class WebpackInputHost implements virtualFs.Host<Stats> {
5151
// TODO: remove this try+catch when issue https://github.com/ReactiveX/rxjs/issues/3740 is
5252
// fixed.
5353
try {
54-
const names = this.inputFileSystem.readdirSync(getSystemPath(path));
54+
// tslint:disable-next-line:no-any
55+
const names: string[] = (this.inputFileSystem as any).readdirSync(getSystemPath(path));
5556
obs.next(names.map(name => fragment(name)));
5657
obs.complete();
5758
} catch (err) {

packages/ngtools/webpack/src/webpack.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
import { Stats } from 'fs';
8+
import { InputFileSystem } from 'webpack';
99

1010
// Declarations for (some) Webpack types. Only what's needed.
1111

@@ -21,21 +21,6 @@ export interface NormalModuleFactoryRequest {
2121
typescriptPathMapped?: boolean;
2222
}
2323

24-
export interface InputFileSystem {
25-
stat(path: string, callback: Callback<Stats>): void;
26-
readdir(path: string, callback: Callback<string[]>): void;
27-
readFile(path: string, callback: Callback<Buffer>): void;
28-
readJson(path: string, callback: Callback): void;
29-
readlink(path: string, callback: Callback<string>): void;
30-
statSync(path: string): Stats;
31-
readdirSync(path: string): string[];
32-
readFileSync(path: string): Buffer;
33-
// tslint:disable-next-line:no-any
34-
readJsonSync(path: string): any;
35-
readlinkSync(path: string): string;
36-
purge(changes?: string[] | string): void;
37-
}
38-
3924
export interface NodeWatchFileSystemInterface {
4025
inputFileSystem: InputFileSystem;
4126
new(inputFileSystem: InputFileSystem): NodeWatchFileSystemInterface;

0 commit comments

Comments
 (0)