Skip to content

Commit

Permalink
fix: improve types
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed Jul 29, 2021
1 parent 9bfc989 commit 098b6dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ A path prefix that will be added to values of the manifest.

### `removeKeyHash`

Type: `RegExp | Boolean`<br>
Type: `RegExp | false`<br>
Default: `/([a-f0-9]{32}\.?)/gi`

If set to a valid `RegExp`, removes hashes from manifest keys. e.g.
Expand Down
4 changes: 2 additions & 2 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { dirname, join, basename } from 'path';

import webpack, { AssetInfo, Chunk } from 'webpack';

import { InternalOptions } from './';
import { InternalOptions, Manifest } from './';

export interface FileDescriptor {
chunk?: ProperChunk;
Expand Down Expand Up @@ -34,7 +34,7 @@ const generateManifest = (
files: FileDescriptor[],
{ generate, seed = {} }: InternalOptions
) => {
let result;
let result: Manifest;
if (generate) {
const entrypointsArray = Array.from(compilation.entrypoints.entries());
const entrypoints = entrypointsArray.reduce(
Expand Down
16 changes: 11 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,23 @@ import { beforeRunHook, emitHook, getCompilerHooks, normalModuleLoaderHook } fro

const emitCountMap: EmitCountMap = new Map();

export type Manifest = Record<string, string>;

export interface InternalOptions {
[key: string]: any;
basePath: string;
fileName: string;
filter: (file: FileDescriptor) => Boolean;
generate: (seed: Record<any, any>, files: FileDescriptor[], entries: Record<string, any>) => any;
generate: (
seed: Record<any, any>,
files: FileDescriptor[],
entries: Record<string, string[]>
) => Manifest;
map: (file: FileDescriptor) => FileDescriptor;
publicPath: string;
removeKeyHash: RegExp;
seed: Record<any, any> | any[];
serialize: (manifest: any) => string;
removeKeyHash: RegExp | false;
seed: Record<any, any>;
serialize: (manifest: Manifest) => string;
sort: (fileA: FileDescriptor, fileB: FileDescriptor) => Number;
transformExtensions: RegExp;
useEntryKeys: Boolean;
Expand Down Expand Up @@ -103,4 +109,4 @@ class WebpackManifestPlugin implements WebpackPluginInstance {
}
}

module.exports = { getCompilerHooks, WebpackManifestPlugin };
export { getCompilerHooks, WebpackManifestPlugin };

0 comments on commit 098b6dd

Please sign in to comment.