Skip to content

Commit c23b68b

Browse files
committed
chore: fix plugin
1 parent 6836ecb commit c23b68b

File tree

3 files changed

+227
-139
lines changed

3 files changed

+227
-139
lines changed

types/index.d.ts

Lines changed: 169 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,136 @@
11
export = MiniCssExtractPlugin;
22
declare class MiniCssExtractPlugin {
3-
/**
4-
* @param {Compiler["webpack"]} webpack
5-
* @returns {CssModuleConstructor}
6-
*/
7-
static getCssModule(webpack: Compiler["webpack"]): CssModuleConstructor;
8-
/**
9-
* @param {Compiler["webpack"]} webpack
10-
* @returns {CssDependencyConstructor}
11-
*/
12-
static getCssDependency(webpack: Compiler["webpack"]): CssDependencyConstructor;
13-
/**
14-
* Returns all hooks for the given compilation
15-
* @param {Compilation} compilation the compilation
16-
* @returns {MiniCssExtractPluginCompilationHooks} hooks
17-
*/
18-
static getCompilationHooks(compilation: Compilation): MiniCssExtractPluginCompilationHooks;
19-
/**
20-
* @param {PluginOptions} [options]
21-
*/
22-
constructor(options?: PluginOptions | undefined);
23-
/**
24-
* @private
25-
* @type {WeakMap<Chunk, Set<CssModule>>}
26-
* @private
27-
*/
28-
private _sortedModulesCache;
29-
/**
30-
* @private
31-
* @type {NormalizedPluginOptions}
32-
*/
33-
private options;
34-
/**
35-
* @private
36-
* @type {RuntimeOptions}
37-
*/
38-
private runtimeOptions;
39-
/**
40-
* @param {Compiler} compiler
41-
*/
42-
apply(compiler: Compiler): void;
43-
/**
44-
* @private
45-
* @param {Chunk} chunk
46-
* @param {ChunkGraph} chunkGraph
47-
* @returns {Iterable<Module>}
48-
*/
49-
private getChunkModules;
50-
/**
51-
* @private
52-
* @param {Compilation} compilation
53-
* @param {Chunk} chunk
54-
* @param {CssModule[]} modules
55-
* @param {Compilation["requestShortener"]} requestShortener
56-
* @returns {Set<CssModule>}
57-
*/
58-
private sortModules;
59-
/**
60-
* @private
61-
* @param {Compiler} compiler
62-
* @param {Compilation} compilation
63-
* @param {Chunk} chunk
64-
* @param {CssModule[]} modules
65-
* @param {Compiler["requestShortener"]} requestShortener
66-
* @param {string} filenameTemplate
67-
* @param {Parameters<Exclude<Required<Configuration>['output']['filename'], string | undefined>>[0]} pathData
68-
* @returns {Source}
69-
*/
70-
private renderContentAsset;
3+
/**
4+
* @param {Compiler["webpack"]} webpack
5+
* @returns {CssModuleConstructor}
6+
*/
7+
static getCssModule(webpack: Compiler["webpack"]): CssModuleConstructor;
8+
/**
9+
* @param {Compiler["webpack"]} webpack
10+
* @returns {CssDependencyConstructor}
11+
*/
12+
static getCssDependency(
13+
webpack: Compiler["webpack"]
14+
): CssDependencyConstructor;
15+
/**
16+
* Returns all hooks for the given compilation
17+
* @param {Compilation} compilation the compilation
18+
* @returns {MiniCssExtractPluginCompilationHooks} hooks
19+
*/
20+
static getCompilationHooks(
21+
compilation: Compilation
22+
): MiniCssExtractPluginCompilationHooks;
23+
/**
24+
* @param {PluginOptions} [options]
25+
*/
26+
constructor(options?: PluginOptions | undefined);
27+
/**
28+
* @private
29+
* @type {WeakMap<Chunk, Set<CssModule>>}
30+
* @private
31+
*/
32+
private _sortedModulesCache;
33+
/**
34+
* @private
35+
* @type {NormalizedPluginOptions}
36+
*/
37+
private options;
38+
/**
39+
* @private
40+
* @type {RuntimeOptions}
41+
*/
42+
private runtimeOptions;
43+
/**
44+
* @param {Compiler} compiler
45+
*/
46+
apply(compiler: Compiler): void;
47+
/**
48+
* @private
49+
* @param {Chunk} chunk
50+
* @param {ChunkGraph} chunkGraph
51+
* @returns {Iterable<Module>}
52+
*/
53+
private getChunkModules;
54+
/**
55+
* @private
56+
* @param {Compilation} compilation
57+
* @param {Chunk} chunk
58+
* @param {CssModule[]} modules
59+
* @param {Compilation["requestShortener"]} requestShortener
60+
* @returns {Set<CssModule>}
61+
*/
62+
private sortModules;
63+
/**
64+
* @private
65+
* @param {Compiler} compiler
66+
* @param {Compilation} compilation
67+
* @param {Chunk} chunk
68+
* @param {CssModule[]} modules
69+
* @param {Compiler["requestShortener"]} requestShortener
70+
* @param {string} filenameTemplate
71+
* @param {Parameters<Exclude<Required<Configuration>['output']['filename'], string | undefined>>[0]} pathData
72+
* @returns {Source}
73+
*/
74+
private renderContentAsset;
7175
}
7276
declare namespace MiniCssExtractPlugin {
73-
export { pluginName, pluginSymbol, loader, Schema, Compiler, Compilation, ChunkGraph, Chunk, ChunkGroup, Module, Dependency, Source, Configuration, WebpackError, AssetInfo, LoaderDependency, LoaderOptions, PluginOptions, NormalizedPluginOptions, RuntimeOptions, TODO, CssModule, CssModuleDependency, CssModuleConstructor, CssDependency, CssDependencyOptions, CssDependencyConstructor, VarNames, MiniCssExtractPluginCompilationHooks };
77+
export {
78+
pluginName,
79+
pluginSymbol,
80+
loader,
81+
Schema,
82+
Compiler,
83+
Compilation,
84+
ChunkGraph,
85+
Chunk,
86+
ChunkGroup,
87+
Module,
88+
Dependency,
89+
Source,
90+
Configuration,
91+
WebpackError,
92+
AssetInfo,
93+
LoaderDependency,
94+
LoaderOptions,
95+
PluginOptions,
96+
NormalizedPluginOptions,
97+
RuntimeOptions,
98+
TODO,
99+
CssModule,
100+
CssModuleDependency,
101+
CssModuleConstructor,
102+
CssDependency,
103+
CssDependencyOptions,
104+
CssDependencyConstructor,
105+
VarNames,
106+
MiniCssExtractPluginCompilationHooks,
107+
};
74108
}
75109
type Compiler = import("webpack").Compiler;
76110
type CssModuleConstructor = new (dependency: CssModuleDependency) => CssModule;
77-
type CssDependencyConstructor = new (loaderDependency: CssDependencyOptions, context: string | null, identifierIndex: number) => CssDependency;
111+
type CssDependencyConstructor = new (
112+
loaderDependency: CssDependencyOptions,
113+
context: string | null,
114+
identifierIndex: number
115+
) => CssDependency;
78116
type Compilation = import("webpack").Compilation;
79117
type MiniCssExtractPluginCompilationHooks = {
80-
beforeTagInsert: import("tapable").SyncWaterfallHook<[string, VarNames], string>;
81-
linkPreload: SyncWaterfallHook<[string, Chunk]>;
82-
linkPrefetch: SyncWaterfallHook<[string, Chunk]>;
118+
beforeTagInsert: import("tapable").SyncWaterfallHook<
119+
[string, VarNames],
120+
string
121+
>;
122+
linkPreload: SyncWaterfallHook<[string, Chunk]>;
123+
linkPrefetch: SyncWaterfallHook<[string, Chunk]>;
83124
};
84125
type PluginOptions = {
85-
filename?: Required<Configuration>['output']['filename'];
86-
chunkFilename?: Required<Configuration>['output']['chunkFilename'];
87-
ignoreOrder?: boolean | undefined;
88-
insert?: string | ((linkTag: HTMLLinkElement) => void) | undefined;
89-
attributes?: Record<string, string> | undefined;
90-
linkType?: string | false | undefined;
91-
runtime?: boolean | undefined;
92-
experimentalUseImportModule?: boolean | undefined;
126+
filename?: Required<Configuration>["output"]["filename"];
127+
chunkFilename?: Required<Configuration>["output"]["chunkFilename"];
128+
ignoreOrder?: boolean | undefined;
129+
insert?: string | ((linkTag: HTMLLinkElement) => void) | undefined;
130+
attributes?: Record<string, string> | undefined;
131+
linkType?: string | false | undefined;
132+
runtime?: boolean | undefined;
133+
experimentalUseImportModule?: boolean | undefined;
93134
};
94135
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
95136
/** @typedef {import("webpack").Compiler} Compiler */
@@ -156,60 +197,67 @@ type WebpackError = import("webpack").WebpackError;
156197
type AssetInfo = import("webpack").AssetInfo;
157198
type LoaderDependency = import("./loader.js").Dependency;
158199
type LoaderOptions = {
159-
publicPath?: string | ((resourcePath: string, rootContext: string) => string) | undefined;
160-
emit?: boolean | undefined;
161-
esModule?: boolean | undefined;
162-
layer?: string | undefined;
163-
defaultExport?: boolean | undefined;
200+
publicPath?:
201+
| string
202+
| ((resourcePath: string, rootContext: string) => string)
203+
| undefined;
204+
emit?: boolean | undefined;
205+
esModule?: boolean | undefined;
206+
layer?: string | undefined;
207+
defaultExport?: boolean | undefined;
164208
};
165209
type NormalizedPluginOptions = {
166-
filename: Required<Configuration>['output']['filename'];
167-
chunkFilename?: Required<Configuration>['output']['chunkFilename'];
168-
ignoreOrder: boolean;
169-
insert?: string | ((linkTag: HTMLLinkElement) => void) | undefined;
170-
attributes?: Record<string, string> | undefined;
171-
linkType?: string | false | undefined;
172-
runtime: boolean;
173-
experimentalUseImportModule?: boolean | undefined;
210+
filename: Required<Configuration>["output"]["filename"];
211+
chunkFilename?: Required<Configuration>["output"]["chunkFilename"];
212+
ignoreOrder: boolean;
213+
insert?: string | ((linkTag: HTMLLinkElement) => void) | undefined;
214+
attributes?: Record<string, string> | undefined;
215+
linkType?: string | false | undefined;
216+
runtime: boolean;
217+
experimentalUseImportModule?: boolean | undefined;
174218
};
175219
type RuntimeOptions = {
176-
insert: string | ((linkTag: HTMLLinkElement) => void) | undefined;
177-
linkType: string | false | 'text/css';
178-
attributes: Record<string, string> | undefined;
220+
insert: string | ((linkTag: HTMLLinkElement) => void) | undefined;
221+
linkType: string | false | "text/css";
222+
attributes: Record<string, string> | undefined;
179223
};
180224
type TODO = any;
181225
type CssModule = import("webpack").Module & {
182-
content: Buffer;
183-
media?: string | undefined;
184-
sourceMap?: Buffer | undefined;
185-
supports?: string | undefined;
186-
layer?: string | undefined;
187-
assets?: {
226+
content: Buffer;
227+
media?: string | undefined;
228+
sourceMap?: Buffer | undefined;
229+
supports?: string | undefined;
230+
layer?: string | undefined;
231+
assets?:
232+
| {
188233
[key: string]: any;
189-
} | undefined;
190-
assetsInfo?: Map<string, import("webpack").AssetInfo> | undefined;
234+
}
235+
| undefined;
236+
assetsInfo?: Map<string, import("webpack").AssetInfo> | undefined;
191237
};
192238
type CssModuleDependency = {
193-
context: string | null;
194-
identifier: string;
195-
identifierIndex: number;
196-
content: Buffer;
197-
sourceMap?: Buffer | undefined;
198-
media?: string | undefined;
199-
supports?: string | undefined;
200-
layer?: TODO;
201-
assetsInfo?: Map<string, import("webpack").AssetInfo> | undefined;
202-
assets?: {
239+
context: string | null;
240+
identifier: string;
241+
identifierIndex: number;
242+
content: Buffer;
243+
sourceMap?: Buffer | undefined;
244+
media?: string | undefined;
245+
supports?: string | undefined;
246+
layer?: TODO;
247+
assetsInfo?: Map<string, import("webpack").AssetInfo> | undefined;
248+
assets?:
249+
| {
203250
[key: string]: any;
204-
} | undefined;
251+
}
252+
| undefined;
205253
};
206254
type CssDependency = Dependency & CssModuleDependency;
207255
type CssDependencyOptions = Omit<LoaderDependency, "context">;
208256
type VarNames = {
209-
tag: string;
210-
chunkId: string;
211-
href: string;
212-
resolve: string;
213-
reject: string;
257+
tag: string;
258+
chunkId: string;
259+
href: string;
260+
resolve: string;
261+
reject: string;
214262
};
215263
import { SyncWaterfallHook } from "tapable";

0 commit comments

Comments
 (0)