@@ -48,23 +48,35 @@ The available options are:
4848 } ;
4949 }
5050
51- // if "children" is set, set selectedChunks to false instead of specified chunks
52- // TODO: why? :P
53- const selectedChunks = options . children ? false : options . chunks ;
51+ // options.children and options.chunk may not be used together
52+ if ( options . children && options . chunks ) {
53+ throw new Error ( "You can't and it does not make any sense to use \"children\" and \"chunk\" options together." ) ;
54+ }
55+
56+ /**
57+ * options.async and options.filename are also not possible together
58+ * as filename specifies how the chunk is called but "async" implies
59+ * that webpack will take care of loading this file.
60+ */
61+ if ( options . async && options . filename ) {
62+ throw new Error ( "If you set the \"async\" option webpack takes care of loading the chunk. Therefore you can not specify a filename." ) ;
63+ }
64+
5465 const chunkNames = options . name ? [ options . name ] : options . names ;
5566 return {
5667 chunkNames : chunkNames ,
5768 filenameTemplate : options . filename ,
5869 minChunks : options . minChunks ,
59- selectedChunks : selectedChunks ,
70+ selectedChunks : options . chunks ,
71+ children : options . children ,
6072 async : options . async ,
6173 minSize : options . minSize ,
6274 ident : __filename + ( nextIdent ++ ) ,
6375 } ;
6476 }
6577
66- getCommonChunks ( allChunks , compilation , chunkNames , selectedChunks , async ) {
67- const asyncOrNoSelectedChunk = selectedChunks === false || async ;
78+ getCommonChunks ( allChunks , compilation , chunkNames , selectedChunks , asyncOption ) {
79+ const asyncOrNoSelectedChunk = selectedChunks === false || asyncOption ;
6880
6981 // we have specified chunk names
7082 if ( chunkNames ) {
@@ -94,8 +106,8 @@ The available options are:
94106 throw new Error ( "Invalid chunkNames argument" ) ;
95107 }
96108
97- getUsedChunks ( compilation , allChunks , commonChunk , commonChunks , currentIndex , selectedChunks , isAsync ) {
98- const asyncOrNoSelectedChunk = selectedChunks === false || isAsync ;
109+ getUsedChunks ( compilation , allChunks , commonChunk , commonChunks , currentIndex , selectedChunks , asyncOption ) {
110+ const asyncOrNoSelectedChunk = selectedChunks === false || asyncOption ;
99111
100112 if ( Array . isArray ( selectedChunks ) ) {
101113 return allChunks . filter ( chunk => {
@@ -113,7 +125,7 @@ The available options are:
113125
114126 return commonChunk . chunks . filter ( ( chunk ) => {
115127 // we can only move modules from this chunk if the "commonChunk" is the only parent
116- return isAsync || chunk . parents . length === 1 ;
128+ return asyncOption || chunk . parents . length === 1 ;
117129 } ) ;
118130 }
119131
0 commit comments