You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a6d13aa
Browse filesBrowse the repository at this point in the historyBrowse files
* Encodes how a concatenated module reference should be interpreted when it is
@@ -28,6 +42,7 @@ const MODULE_REFERENCE_REGEXP =
28
42
* @property {boolean} directImport true, when this referenced export is directly imported (not via property access)
29
43
* @property {boolean} deferredImport true, when this referenced export is deferred
30
44
* @property {boolean} mangleableNamespace true, when a whole-namespace reference may use a decoupled namespace object that keeps the original export names
45
+
* @property {boolean} moduleExportsAccess true, when the reference resolves to the module's own exports value with plain property access, skipping ESM interop (how `require()` and a wrapped module's side-effect init see it)
31
46
* @property {boolean | undefined} asiSafe if the position is ASI safe or unknown
32
47
*/
33
48
@@ -58,6 +73,10 @@ class ConcatenationScope {
58
73
this.usedNames=usedNames;
59
74
/** @type {Map<Module, ModuleInfo>} */
60
75
this._modulesMap=modulesMap;
76
+
// written and read by dependency templates within a single code
77
+
// generation pass, never across passes
78
+
/** @type {Range[] | undefined} */
79
+
this._replacedRequireRanges=undefined;
61
80
}
62
81
63
82
/**
@@ -69,6 +88,63 @@ class ConcatenationScope {
69
88
returnthis._modulesMap.has(module);
70
89
}
71
90
91
+
/**
92
+
* Whether an in-scope module's body renders inside the lazy wrapper.
93
+
* @param {Module} module the referenced module
94
+
* @returns {boolean} true, when it's wrapped
95
+
*/
96
+
isModuleWrapped(module){
97
+
constinfo=this._modulesMap.get(module);
98
+
returninfo!==undefined&&info.wrapped;
99
+
}
100
+
101
+
/**
102
+
* Marks a wrapped module as eagerly imported, so its accessor is called at its
103
+
* own slot in evaluation order instead of from inside the importing body.
104
+
* @param {Module} module the referenced module
105
+
*/
106
+
registerEagerModule(module){
107
+
constinfo=this._modulesMap.get(module);
108
+
if(info!==undefined)info.eager=true;
109
+
}
110
+
111
+
/**
112
+
* Whether the current module runs inside the lazy wrapper. Exports then live
113
+
* on a real exports object, not hoisted bindings, so templates emit runtime
114
+
* code.
115
+
* @returns {boolean} true, when the current module is wrapped
116
+
*/
117
+
isWrapped(){
118
+
returnthis._currentModule.wrapped;
119
+
}
120
+
121
+
/**
122
+
* Records a `require(...)` call that was replaced as a whole by a
123
+
* concatenation reference, so nothing else rewrites a range inside it.
124
+
* @param {Range} range source range of the replaced call
125
+
*/
126
+
registerReplacedRequire(range){
127
+
if(this._replacedRequireRanges===undefined){
128
+
this._replacedRequireRanges=[];
129
+
}
130
+
this._replacedRequireRanges.push(range);
131
+
}
132
+
133
+
/**
134
+
* Checks whether an offset sits inside an already-replaced `require(...)` call.
135
+
* Containment, not exact match: `new require(...)` is replaced from `new`.
136
+
* @param {number} start start offset to test
137
+
* @returns {boolean} true, when the offset was replaced already
138
+
*/
139
+
isInsideReplacedRequire(start){
140
+
constranges=this._replacedRequireRanges;
141
+
if(ranges===undefined)returnfalse;
142
+
for(const[rangeStart,rangeEnd]ofranges){
143
+
if(start>=rangeStart&&start<rangeEnd)returntrue;
144
+
}
145
+
returnfalse;
146
+
}
147
+
72
148
/**
73
149
* Records the symbol that should be used when the current module exports a
0 commit comments