@@ -33,6 +33,7 @@ class RawDataUrlModule extends Module {
3333 constructor ( url , identifier , readableIdentifier ) {
3434 super ( "asset/raw-data-url" , null ) ;
3535 this . url = url ;
36+ this . urlBuffer = url ? Buffer . from ( url ) : undefined ;
3637 this . identifierStr = identifier || this . url ;
3738 this . readableIdentifierStr = readableIdentifier || this . identifierStr ;
3839 }
@@ -56,6 +57,7 @@ class RawDataUrlModule extends Module {
5657 * @returns {number } the estimated size of the module (must be non-zero)
5758 */
5859 size ( type ) {
60+ if ( this . url === undefined ) this . url = this . urlBuffer . toString ( ) ;
5961 return Math . max ( 1 , this . url . length ) ;
6062 }
6163
@@ -97,13 +99,14 @@ class RawDataUrlModule extends Module {
9799 * @returns {CodeGenerationResult } result
98100 */
99101 codeGeneration ( context ) {
102+ if ( this . url === undefined ) this . url = this . urlBuffer . toString ( ) ;
100103 const sources = new Map ( ) ;
101104 sources . set (
102105 "javascript" ,
103106 new RawSource ( `module.exports = ${ JSON . stringify ( this . url ) } ;` )
104107 ) ;
105108 const data = new Map ( ) ;
106- data . set ( "url" , this . url ) ;
109+ data . set ( "url" , this . urlBuffer ) ;
107110 const runtimeRequirements = new Set ( ) ;
108111 runtimeRequirements . add ( RuntimeGlobals . module ) ;
109112 return { sources, runtimeRequirements, data } ;
@@ -115,14 +118,14 @@ class RawDataUrlModule extends Module {
115118 * @returns {void }
116119 */
117120 updateHash ( hash , context ) {
118- hash . update ( this . url ) ;
121+ hash . update ( this . urlBuffer ) ;
119122 super . updateHash ( hash , context ) ;
120123 }
121124
122125 serialize ( context ) {
123126 const { write } = context ;
124127
125- write ( this . url ) ;
128+ write ( this . urlBuffer ) ;
126129 write ( this . identifierStr ) ;
127130 write ( this . readableIdentifierStr ) ;
128131
@@ -132,7 +135,7 @@ class RawDataUrlModule extends Module {
132135 deserialize ( context ) {
133136 const { read } = context ;
134137
135- this . url = read ( ) ;
138+ this . urlBuffer = read ( ) ;
136139 this . identifierStr = read ( ) ;
137140 this . readableIdentifierStr = read ( ) ;
138141
0 commit comments