@@ -21,7 +21,7 @@ const {
21
21
/** @typedef {import("webpack").Compilation } Compilation */
22
22
/** @typedef {import("webpack").ChunkGraph } ChunkGraph */
23
23
/** @typedef {import("webpack").Chunk } Chunk */
24
- /** @typedef {Parameters< import("webpack").Chunk["isInGroup"]>[0] } ChunkGroup */
24
+ /** @typedef {import("webpack").ChunkGroup } ChunkGroup */
25
25
/** @typedef {import("webpack").Module } Module */
26
26
/** @typedef {import("webpack").Dependency } Dependency */
27
27
/** @typedef {import("webpack").sources.Source } Source */
@@ -30,6 +30,9 @@ const {
30
30
/** @typedef {import("webpack").AssetInfo } AssetInfo */
31
31
/** @typedef {import("./loader.js").Dependency } LoaderDependency */
32
32
33
+ /** @typedef {NonNullable<Required<Configuration>['output']['filename']> } Filename */
34
+ /** @typedef {NonNullable<Required<Configuration>['output']['chunkFilename']> } ChunkFilename */
35
+
33
36
/**
34
37
* @typedef {object } LoaderOptions
35
38
* @property {string | ((resourcePath: string, rootContext: string) => string)= } publicPath public path
@@ -41,8 +44,8 @@ const {
41
44
42
45
/**
43
46
* @typedef {object } PluginOptions
44
- * @property {Required<Configuration>['output']['filename'] = } filename filename
45
- * @property {Required<Configuration>['output']['chunkFilename'] = } chunkFilename chunk filename
47
+ * @property {Filename = } filename filename
48
+ * @property {ChunkFilename = } chunkFilename chunk filename
46
49
* @property {boolean= } ignoreOrder true when need to ignore order, otherwise false
47
50
* @property {string | ((linkTag: HTMLLinkElement) => void)= } insert link insert place or a custom insert function
48
51
* @property {Record<string, string>= } attributes link attributes
@@ -53,8 +56,8 @@ const {
53
56
54
57
/**
55
58
* @typedef {object } NormalizedPluginOptions
56
- * @property {Required<Configuration>['output']['filename'] } filename filename
57
- * @property {Required<Configuration>['output']['chunkFilename'] = } chunkFilename chunk filename
59
+ * @property {Filename } filename filename
60
+ * @property {ChunkFilename = } chunkFilename chunk filename
58
61
* @property {boolean } ignoreOrder true when need to ignore order, otherwise false
59
62
* @property {string | ((linkTag: HTMLLinkElement) => void)= } insert a link insert place or a custom insert function
60
63
* @property {Record<string, string>= } attributes link attributes
@@ -70,9 +73,6 @@ const {
70
73
* @property {Record<string, string>= } attributes link attributes
71
74
*/
72
75
73
- // eslint-disable-next-line jsdoc/no-restricted-syntax
74
- /** @typedef {any } TODO */
75
-
76
76
const pluginName = "mini-css-extract-plugin" ;
77
77
const pluginSymbol = Symbol ( pluginName ) ;
78
78
@@ -89,8 +89,9 @@ const CODE_GENERATION_RESULT = {
89
89
runtimeRequirements : new Set ( ) ,
90
90
} ;
91
91
92
- /** @typedef {Module & { content: Buffer, media?: string, sourceMap?: Buffer, supports?: string, layer?: string, assets?: { [key: string]: TODO }, assetsInfo?: Map<string, AssetInfo> } } CssModule */
93
- /** @typedef {{ context: string | null, identifier: string, identifierIndex: number, content: Buffer, sourceMap?: Buffer, media?: string, supports?: string, layer?: TODO, assetsInfo?: Map<string, AssetInfo>, assets?: { [key: string]: TODO }} } CssModuleDependency */
92
+ // eslint-disable-next-line jsdoc/no-restricted-syntax
93
+ /** @typedef {{ context: string | null, identifier: string, identifierIndex: number, content: Buffer, sourceMap?: Buffer, media?: string, supports?: string, layer?: any, assetsInfo?: Map<string, AssetInfo>, assets?: { [key: string]: Source }} } CssModuleDependency */
94
+ /** @typedef {Module & { content: Buffer, media?: string, sourceMap?: Buffer, supports?: string, layer?: string, assets?: { [key: string]: Source }, assetsInfo?: Map<string, AssetInfo> } } CssModule */
94
95
/** @typedef {{ new(dependency: CssModuleDependency): CssModule } } CssModuleConstructor */
95
96
/** @typedef {Dependency & CssModuleDependency } CssDependency */
96
97
/** @typedef {Omit<LoaderDependency, "context"> } CssDependencyOptions */
@@ -437,10 +438,8 @@ class MiniCssExtractPlugin {
437
438
this . sourceMap = sourceMap ;
438
439
this . context = context ;
439
440
/** @type {{ [key: string]: Source } | undefined }} */
440
-
441
441
this . assets = undefined ;
442
442
/** @type {Map<string, AssetInfo> | undefined } */
443
-
444
443
this . assetsInfo = undefined ;
445
444
}
446
445
@@ -486,7 +485,6 @@ class MiniCssExtractPlugin {
486
485
}
487
486
}
488
487
489
- // @ts -expect-error
490
488
cssDependencyCache . set ( webpack , CssDependency ) ;
491
489
492
490
webpack . util . serialization . register (
@@ -525,7 +523,6 @@ class MiniCssExtractPlugin {
525
523
} ,
526
524
) ;
527
525
528
- // @ts -expect-error
529
526
return CssDependency ;
530
527
}
531
528
@@ -574,7 +571,6 @@ class MiniCssExtractPlugin {
574
571
filename : DEFAULT_FILENAME ,
575
572
ignoreOrder : false ,
576
573
// TODO remove in the next major release
577
-
578
574
experimentalUseImportModule : undefined ,
579
575
runtime : true ,
580
576
...options ,
@@ -639,7 +635,7 @@ class MiniCssExtractPlugin {
639
635
) {
640
636
/** @type {Compiler["options"]["experiments"] & { executeModule?: boolean } } */
641
637
642
- // @ts -expect-error
638
+ // @ts -expect-error TODO remove in the next major release
643
639
compiler . options . experiments . executeModule = true ;
644
640
}
645
641
@@ -692,7 +688,7 @@ class MiniCssExtractPlugin {
692
688
class CssModuleFactory {
693
689
/**
694
690
* @param {{ dependencies: Dependency[] } } dependencies
695
- * @param {(arg0 ?: Error, arg1 ?: TODO ) => void } callback
691
+ * @param {(err ?: null | Error, result ?: CssModule ) => void } callback
696
692
*/
697
693
698
694
create ( { dependencies : [ dependency ] } , callback ) {
@@ -705,6 +701,7 @@ class MiniCssExtractPlugin {
705
701
706
702
compilation . dependencyFactories . set (
707
703
CssDependency ,
704
+ // @ts -expect-error TODO fix in the next major release and fix using `CssModuleFactory extends webpack.ModuleFactory`
708
705
new CssModuleFactory ( ) ,
709
706
) ;
710
707
@@ -722,7 +719,7 @@ class MiniCssExtractPlugin {
722
719
/**
723
720
* @param {ReturnType<Compilation["getRenderManifest"]> } result result
724
721
* @param {Parameters<Compilation["getRenderManifest"]>[0] } chunk chunk
725
- * @returns {TODO } a rendered manifest
722
+ * @returns {ReturnType<Compilation["getRenderManifest"]> } a rendered manifest
726
723
*/
727
724
( result , { chunk } ) => {
728
725
const { chunkGraph } = compilation ;
@@ -731,7 +728,7 @@ class MiniCssExtractPlugin {
731
728
// We don't need hot update chunks for css
732
729
// We will use the real asset instead to update
733
730
if ( chunk instanceof HotUpdateChunk ) {
734
- return ;
731
+ return result ;
735
732
}
736
733
737
734
const renderedModules =
@@ -774,6 +771,8 @@ class MiniCssExtractPlugin {
774
771
hash : chunk . contentHash [ MODULE_TYPE ] ,
775
772
} ) ;
776
773
}
774
+
775
+ return result ;
777
776
} ,
778
777
) ;
779
778
@@ -1232,16 +1231,16 @@ class MiniCssExtractPlugin {
1232
1231
`${ RuntimeGlobals . require } .miniCssF` ,
1233
1232
/**
1234
1233
* @param {Chunk } referencedChunk a referenced chunk
1235
- * @returns {TODO } a template value
1234
+ * @returns {ReturnType<import("webpack").runtime.GetChunkFilenameRuntimeModule["getFilenameForChunk"]> } a template value
1236
1235
*/
1237
1236
( referencedChunk ) => {
1238
1237
if ( ! referencedChunk . contentHash [ MODULE_TYPE ] ) {
1239
1238
return false ;
1240
1239
}
1241
1240
1242
1241
return referencedChunk . canBeInitial ( )
1243
- ? this . options . filename
1244
- : this . options . chunkFilename ;
1242
+ ? /** @type { Filename } */ ( this . options . filename )
1243
+ : /** @type { ChunkFilename } */ ( this . options . chunkFilename ) ;
1245
1244
} ,
1246
1245
set . has ( RuntimeGlobals . hmrDownloadUpdateHandlers ) ,
1247
1246
) ,
0 commit comments