Skip to content

Commit 0fe877b

Browse files
committed
Simplifying the chunk ID type.
1 parent 3d687ec commit 0fe877b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

webpack/resolve-chunk-plugin/src/ResolveChunkPlugin.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ const ParserHelpers: IParserHelper = require('webpack/lib/ParserHelpers');
1111
const EXPRESSION_NAME: string = 'resolveChunk';
1212
const PLUGIN_NAME: string = 'resolve-chunk-plugin';
1313

14+
type ChunkId = number | string | undefined;
15+
1416
/**
1517
* See README for documentation on this plugin.
1618
*
1719
* @public
1820
*/
1921
export class ResolveChunkPlugin implements Webpack.Plugin {
20-
private _chunkIdMap: Map<string, ((id: number | undefined) => void)[]> =
21-
new Map<string, ((id: number | undefined) => void)[]>();
22+
private _chunkIdMap: Map<string, ((id: ChunkId) => void)[]> = new Map<string, ((id: ChunkId) => void)[]>();
2223

2324
/**
2425
* Apply the plugin to the compilation.
@@ -78,7 +79,7 @@ export class ResolveChunkPlugin implements Webpack.Plugin {
7879

7980
const state: IModule = parser.state.current;
8081
const addDependencyFn: ((dependency: IConstDependency) => void) = state.addDependency.bind(state);
81-
(this._chunkIdMap.get(chunkName) || []).push((id: number | string | undefined) => {
82+
(this._chunkIdMap.get(chunkName) || []).push((id: ChunkId) => {
8283
let value: string;
8384
if (id) {
8485
const normalizedId: string | number = typeof id === 'number' ? id : `"${id}"`;
@@ -109,7 +110,7 @@ export class ResolveChunkPlugin implements Webpack.Plugin {
109110
}
110111
}
111112

112-
this._chunkIdMap.forEach((dependencyFns: ((id: number | undefined) => void)[], chunkName: string) => {
113+
this._chunkIdMap.forEach((dependencyFns: ((id: ChunkId) => void)[], chunkName: string) => {
113114
for (const dependencyFn of dependencyFns) {
114115
// Replace with an error function
115116
dependencyFn(undefined);

0 commit comments

Comments
 (0)