@@ -14,11 +14,27 @@ const ModuleDependency = require("./ModuleDependency");
1414/** @typedef {import("../util/runtime").RuntimeSpec } RuntimeSpec */
1515
1616class ContextElementDependency extends ModuleDependency {
17- constructor ( request , userRequest , typePrefix , category , referencedExports ) {
17+ /**
18+ * @param {string } request request
19+ * @param {string|undefined } userRequest user request
20+ * @param {string } typePrefix type prefix
21+ * @param {string } category category
22+ * @param {string[][]= } referencedExports referenced exports
23+ * @param {string= } context context
24+ */
25+ constructor (
26+ request ,
27+ userRequest ,
28+ typePrefix ,
29+ category ,
30+ referencedExports ,
31+ context
32+ ) {
1833 super ( request ) ;
1934 this . referencedExports = referencedExports ;
2035 this . _typePrefix = typePrefix ;
2136 this . _category = category ;
37+ this . _context = context || undefined ;
2238
2339 if ( userRequest ) {
2440 this . userRequest = userRequest ;
@@ -33,6 +49,20 @@ class ContextElementDependency extends ModuleDependency {
3349 return "context element" ;
3450 }
3551
52+ /**
53+ * @returns {string | undefined } a request context
54+ */
55+ getContext ( ) {
56+ return this . _context ;
57+ }
58+
59+ /**
60+ * @returns {string | null } an identifier to merge equal requests
61+ */
62+ getResourceIdentifier ( ) {
63+ return `context${ this . _context || "" } |${ super . getResourceIdentifier ( ) } ` ;
64+ }
65+
3666 get category ( ) {
3767 return this . _category ;
3868 }
@@ -56,6 +86,7 @@ class ContextElementDependency extends ModuleDependency {
5686 const { write } = context ;
5787 write ( this . _typePrefix ) ;
5888 write ( this . _category ) ;
89+ write ( this . _context ) ;
5990 write ( this . referencedExports ) ;
6091 super . serialize ( context ) ;
6192 }
@@ -64,6 +95,7 @@ class ContextElementDependency extends ModuleDependency {
6495 const { read } = context ;
6596 this . _typePrefix = read ( ) ;
6697 this . _category = read ( ) ;
98+ this . _context = read ( ) ;
6799 this . referencedExports = read ( ) ;
68100 super . deserialize ( context ) ;
69101 }
0 commit comments