juxscript 1.1.290 → 1.1.291
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/machinery/autowrap.js +4 -2
- package/package.json +1 -1
package/machinery/autowrap.js
CHANGED
|
@@ -189,16 +189,18 @@ export function autowrap(source, filename = '') {
|
|
|
189
189
|
|
|
190
190
|
// VariableDeclaration reading pageState — group with subsequent stmts that use declared vars
|
|
191
191
|
if (stmt.type === 'VariableDeclaration' && containsPageStateRef(stmt)) {
|
|
192
|
-
const varNames = getDeclaredVarNames(stmt);
|
|
192
|
+
const varNames = [...getDeclaredVarNames(stmt)];
|
|
193
193
|
const groupStmts = [stmt];
|
|
194
194
|
let j = i + 1;
|
|
195
195
|
|
|
196
196
|
// Greedily consume following statements that use any of the declared variable names
|
|
197
197
|
while (j < ast.body.length) {
|
|
198
198
|
const next = ast.body[j];
|
|
199
|
-
if
|
|
199
|
+
// Check variable dependency FIRST — if it uses our vars, consume it
|
|
200
200
|
if (varNames.some(v => usesIdentifier(next, v))) {
|
|
201
201
|
groupStmts.push(next);
|
|
202
|
+
// Track any new variable declarations in the consumed statement
|
|
203
|
+
getDeclaredVarNames(next).forEach(v => varNames.push(v));
|
|
202
204
|
j++;
|
|
203
205
|
} else {
|
|
204
206
|
break;
|