ProvideSharedDependency.js (1359B)
1 /* 2 MIT License http://www.opensource.org/licenses/mit-license.php 3 Author Tobias Koppers @sokra 4 */ 5 6 "use strict"; 7 8 const Dependency = require("../Dependency"); 9 const makeSerializable = require("../util/makeSerializable"); 10 11 class ProvideSharedDependency extends Dependency { 12 constructor(shareScope, name, version, request, eager) { 13 super(); 14 this.shareScope = shareScope; 15 this.name = name; 16 this.version = version; 17 this.request = request; 18 this.eager = eager; 19 } 20 21 get type() { 22 return "provide shared module"; 23 } 24 25 /** 26 * @returns {string | null} an identifier to merge equal requests 27 */ 28 getResourceIdentifier() { 29 return `provide module (${this.shareScope}) ${this.request} as ${ 30 this.name 31 } @ ${this.version}${this.eager ? " (eager)" : ""}`; 32 } 33 34 serialize(context) { 35 context.write(this.shareScope); 36 context.write(this.name); 37 context.write(this.request); 38 context.write(this.version); 39 context.write(this.eager); 40 super.serialize(context); 41 } 42 43 static deserialize(context) { 44 const { read } = context; 45 const obj = new ProvideSharedDependency( 46 read(), 47 read(), 48 read(), 49 read(), 50 read() 51 ); 52 this.shareScope = context.read(); 53 obj.deserialize(context); 54 return obj; 55 } 56 } 57 58 makeSerializable( 59 ProvideSharedDependency, 60 "webpack/lib/sharing/ProvideSharedDependency" 61 ); 62 63 module.exports = ProvideSharedDependency;