@@ -30,40 +30,15 @@ const PLUGIN_LOGGER_NAME = `webpack.${PLUGIN_NAME}`;
3030/** @typedef {{ etag: string, data: InstanceType<RestoreProvidedData> } } MemCacheEntry */
3131
3232/**
33- * Cache key fragment for what changes provided exports without changing the
34- * module's source: still-lazy barrel requests and DefinePlugin value versions.
3533 * @param {Module } module the module
3634 * @param {LazyBarrelController } lazyBarrelController the compilation's lazy barrel controller
3735 * @param {HashFunction } hashFunction hash function for long keys
38- * @returns {string } etag for provided-exports mem/persistent cache, "" when neither applies
36+ * @returns {string } the hash
3937 */
40- const getProvidedExportsEtag = ( module , lazyBarrelController , hashFunction ) => {
41- const lazyRequests = lazyBarrelController . getLazyRequests ( module ) ;
42- const buildInfo = /** @type {BuildInfo | undefined } */ ( module . buildInfo ) ;
43- const valueDependencies = buildInfo && buildInfo . valueDependencies ;
44- const hasValueDependencies =
45- valueDependencies !== undefined && valueDependencies . size > 0 ;
46- if ( ! lazyRequests && ! hasValueDependencies ) return "" ;
47- /** @type {(string | string[] | undefined)[][] } */
48- const valueEntries = [ ] ;
49- if ( hasValueDependencies ) {
50- const versions =
51- /** @type {NonNullable<BuildInfo["valueDependencies"]> } */
52- ( valueDependencies ) ;
53- for ( const key of [ ...versions . keys ( ) ] . sort ( ) ) {
54- const value = versions . get ( key ) ;
55- // An absent version serializes as null, distinct from both other shapes
56- valueEntries . push ( [
57- key ,
58- value instanceof Set ? [ ...value ] . sort ( ) : value
59- ] ) ;
60- }
61- }
62- // JSON, so a separator inside a request or a version cannot forge another entry
63- const joined = JSON . stringify ( [
64- lazyRequests ? [ ...lazyRequests ] : [ ] ,
65- valueEntries
66- ] ) ;
38+ const getLazyRequestsHash = ( module , lazyBarrelController , hashFunction ) => {
39+ const lazyKeys = lazyBarrelController . getLazyRequests ( module ) ;
40+ if ( ! lazyKeys ) return "" ;
41+ const joined = [ ...lazyKeys ] . join ( "|" ) ;
6742 if ( joined . length < 100 ) return joined ;
6843 const hash = createHash ( hashFunction ) ;
6944 hash . update ( joined ) ;
@@ -132,7 +107,7 @@ class FlagDependencyExportsPlugin {
132107 const memCache = moduleMemCaches && moduleMemCaches . get ( module ) ;
133108 /** @type {MemCacheEntry | undefined } */
134109 const memCacheEntry = memCache && memCache . get ( this ) ;
135- const etag = getProvidedExportsEtag (
110+ const hash = getLazyRequestsHash (
136111 module ,
137112 lazyBarrelController ,
138113 hashFunction
@@ -141,7 +116,7 @@ class FlagDependencyExportsPlugin {
141116 // detection cannot invalidate the mem cache when the un-lazied
142117 // connections are unsafe-cached (they are skipped when comparing
143118 // references)
144- if ( memCacheEntry !== undefined && memCacheEntry . etag === etag ) {
119+ if ( memCacheEntry !== undefined && memCacheEntry . etag === hash ) {
145120 statRestoredFromMemCache ++ ;
146121 exportsInfo . restoreProvided ( memCacheEntry . data ) ;
147122 return callback ( ) ;
@@ -151,7 +126,7 @@ class FlagDependencyExportsPlugin {
151126 ) ;
152127 cache . get (
153128 module . identifier ( ) ,
154- etag ? `${ buildHash } |${ etag } ` : buildHash ,
129+ hash ? `${ buildHash } |${ hash } ` : buildHash ,
155130 ( err , result ) => {
156131 if ( err ) return callback ( err ) ;
157132
@@ -374,13 +349,12 @@ class FlagDependencyExportsPlugin {
374349 changed = true ;
375350 }
376351
377- if ( inlined !== undefined ) {
378- const prev = exportInfo . canInlineProvide ;
379- // Watch rebuilds keep ExportInfo; refresh when the constant changes
380- if ( prev === undefined || ! prev . equals ( inlined ) ) {
381- exportInfo . canInlineProvide = inlined ;
382- changed = true ;
383- }
352+ if (
353+ inlined !== undefined &&
354+ exportInfo . canInlineProvide === undefined
355+ ) {
356+ exportInfo . canInlineProvide = inlined ;
357+ changed = true ;
384358 }
385359
386360 if ( terminalBinding && ! exportInfo . terminalBinding ) {
@@ -537,15 +511,15 @@ class FlagDependencyExportsPlugin {
537511 . getRestoreProvidedData ( ) ;
538512 const memCache =
539513 moduleMemCaches && moduleMemCaches . get ( module ) ;
540- const etag = getProvidedExportsEtag (
514+ const hash = getLazyRequestsHash (
541515 module ,
542516 lazyBarrelController ,
543517 hashFunction
544518 ) ;
545519 if ( memCache ) {
546520 /** @type {MemCacheEntry } */
547521 const entry = {
548- etag,
522+ etag : hash ,
549523 data : cachedData
550524 } ;
551525 memCache . set ( this , entry ) ;
@@ -555,7 +529,7 @@ class FlagDependencyExportsPlugin {
555529 ) ;
556530 cache . store (
557531 module . identifier ( ) ,
558- etag ? `${ buildHash } |${ etag } ` : buildHash ,
532+ hash ? `${ buildHash } |${ hash } ` : buildHash ,
559533 cachedData ,
560534 callback
561535 ) ;
0 commit comments