@@ -13,7 +13,6 @@ const NullDependency = require("./NullDependency");
1313/** @typedef {import("webpack-sources").ReplaceSource } ReplaceSource */
1414/** @typedef {import("../ChunkGraph") } ChunkGraph */
1515/** @typedef {import("../Dependency") } Dependency */
16- /** @typedef {import("../Generator").GenerateContext } GenerateContext */
1716/** @typedef {import("../Dependency").UpdateHashContext } UpdateHashContext */
1817/** @typedef {import("../DependencyTemplate").DependencyTemplateContext } DependencyTemplateContext */
1918/** @typedef {import("../DependencyTemplates") } DependencyTemplates */
@@ -22,19 +21,12 @@ const NullDependency = require("./NullDependency");
2221/** @typedef {import("../util/Hash") } Hash */
2322
2423class CachedConstDependency extends NullDependency {
25- /**
26- * @param {string } expression expression
27- * @param {number|[number, number] } range range
28- * @param {string } identifier identifier
29- * @param {InitFragment<GenerateContext>[]= } initFragments init fragments
30- */
31- constructor ( expression , range , identifier , initFragments ) {
24+ constructor ( expression , range , identifier ) {
3225 super ( ) ;
3326
3427 this . expression = expression ;
3528 this . range = range ;
3629 this . identifier = identifier ;
37- this . initFragments = initFragments ;
3830 }
3931
4032 /**
@@ -44,14 +36,9 @@ class CachedConstDependency extends NullDependency {
4436 * @returns {void }
4537 */
4638 updateHash ( hash , context ) {
47- hash . update ( `${ this . identifier } ` ) ;
48- hash . update ( `${ this . range } ` ) ;
49- hash . update ( `${ this . expression } ` ) ;
50-
51- if ( this . initFragments ) {
52- for ( const fragment of this . initFragments )
53- hash . update ( `${ fragment . key } _${ fragment . position } ` ) ;
54- }
39+ hash . update ( this . identifier + "" ) ;
40+ hash . update ( this . range + "" ) ;
41+ hash . update ( this . expression + "" ) ;
5542 }
5643
5744 serialize ( context ) {
@@ -60,7 +47,6 @@ class CachedConstDependency extends NullDependency {
6047 write ( this . expression ) ;
6148 write ( this . range ) ;
6249 write ( this . identifier ) ;
63- write ( this . initFragments ) ;
6450
6551 super . serialize ( context ) ;
6652 }
@@ -71,7 +57,6 @@ class CachedConstDependency extends NullDependency {
7157 this . expression = read ( ) ;
7258 this . range = read ( ) ;
7359 this . identifier = read ( ) ;
74- this . initFragments = read ( ) ;
7560
7661 super . deserialize ( context ) ;
7762 }
@@ -91,29 +76,16 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
9176 * @param {DependencyTemplateContext } templateContext the context object
9277 * @returns {void }
9378 */
94- apply (
95- dependency ,
96- source ,
97- { runtimeTemplate, dependencyTemplates, initFragments }
98- ) {
79+ apply ( dependency , source , { runtimeTemplate, initFragments } ) {
9980 const dep = /** @type {CachedConstDependency } */ ( dependency ) ;
10081
101- let position = 0 ;
102-
103- if ( dep . initFragments && dep . initFragments . length > 0 ) {
104- for ( const fragment of dep . initFragments ) {
105- initFragments . push ( fragment ) ;
106- }
107- position = dep . initFragments [ dep . initFragments . length - 1 ] . position + 1 ;
108- }
109-
11082 initFragments . push (
11183 new InitFragment (
11284 `${ runtimeTemplate . supportsConst ( ) ? "const" : "var" } ${
11385 dep . identifier
11486 } = ${ dep . expression } ;\n`,
11587 InitFragment . STAGE_CONSTANTS ,
116- position ,
88+ 0 ,
11789 `const ${ dep . identifier } `
11890 )
11991 ) ;
0 commit comments