Skip to content

Commit 1ae28fa

Browse files
committed
[compiler][snap] Fixes to relative path resolution; compile subcommand (facebook#35688)
More snap improvements for use with agents: * `yarn snap compile [--debug] <path>` for compiling any file, optionally with debug logs * `yarn snap minimize <path>` now accepts path as a positional param for consistency w 'compile' command * Both compile/minimize commands properly handle paths relative to the compiler/ directory. When using `yarn snap` the current working directory is compiler/packages/snap, but you're generally running it from the compiler directory so this matches expectations of callers better. DiffTrain build for [3ce1316](facebook@3ce1316)
1 parent 81fc00c commit 1ae28fa

36 files changed

+1416
-1251
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 37 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -19127,7 +19127,8 @@ function printTerminal(terminal) {
1912719127
break;
1912819128
}
1912919129
case 'maybe-throw': {
19130-
value = `[${terminal.id}] MaybeThrow continuation=bb${terminal.continuation} handler=bb${terminal.handler}`;
19130+
const handlerStr = terminal.handler !== null ? `bb${terminal.handler}` : '(none)';
19131+
value = `[${terminal.id}] MaybeThrow continuation=bb${terminal.continuation} handler=${handlerStr}`;
1913119132
if (terminal.effects != null) {
1913219133
value += `\n ${terminal.effects.map(printAliasingEffect).join('\n ')}`;
1913319134
}
@@ -20529,7 +20530,7 @@ function mapTerminalSuccessors(terminal, fn) {
2052920530
}
2053020531
case 'maybe-throw': {
2053120532
const continuation = fn(terminal.continuation);
20532-
const handler = fn(terminal.handler);
20533+
const handler = terminal.handler !== null ? fn(terminal.handler) : null;
2053320534
return {
2053420535
kind: 'maybe-throw',
2053520536
continuation,
@@ -20680,7 +20681,9 @@ function* eachTerminalSuccessor(terminal) {
2068020681
}
2068120682
case 'maybe-throw': {
2068220683
yield terminal.continuation;
20683-
yield terminal.handler;
20684+
if (terminal.handler !== null) {
20685+
yield terminal.handler;
20686+
}
2068420687
break;
2068520688
}
2068620689
case 'try': {
@@ -34221,13 +34224,7 @@ function pruneMaybeThrowsImpl(fn) {
3422134224
if (!canThrow) {
3422234225
const source = (_a = terminalMapping.get(block.id)) !== null && _a !== void 0 ? _a : block.id;
3422334226
terminalMapping.set(terminal.continuation, source);
34224-
block.terminal = {
34225-
kind: 'goto',
34226-
block: terminal.continuation,
34227-
variant: GotoVariant.Break,
34228-
id: terminal.id,
34229-
loc: terminal.loc,
34230-
};
34227+
terminal.handler = null;
3423134228
}
3423234229
}
3423334230
return terminalMapping.size > 0 ? terminalMapping : null;
@@ -35421,6 +35418,31 @@ class Driver {
3542135418
};
3542235419
return { block: blockId, place, value: sequence, id: instr.id };
3542335420
}
35421+
valueBlockResultToSequence(result, loc) {
35422+
const instructions = [];
35423+
let innerValue = result.value;
35424+
while (innerValue.kind === 'SequenceExpression') {
35425+
instructions.push(...innerValue.instructions);
35426+
innerValue = innerValue.value;
35427+
}
35428+
const isLoadOfSamePlace = innerValue.kind === 'LoadLocal' &&
35429+
innerValue.place.identifier.id === result.place.identifier.id;
35430+
if (!isLoadOfSamePlace) {
35431+
instructions.push({
35432+
id: result.id,
35433+
lvalue: result.place,
35434+
value: innerValue,
35435+
loc,
35436+
});
35437+
}
35438+
return {
35439+
kind: 'SequenceExpression',
35440+
instructions,
35441+
id: result.id,
35442+
value: { kind: 'Primitive', value: undefined, loc },
35443+
loc,
35444+
};
35445+
}
3542435446
traverseBlock(block) {
3542535447
const blockValue = [];
3542635448
this.visitBlock(block, blockValue);
@@ -35673,30 +35695,7 @@ class Driver {
3567335695
const scheduleId = this.cx.scheduleLoop(terminal.fallthrough, (_a = terminal.update) !== null && _a !== void 0 ? _a : terminal.test, terminal.loop);
3567435696
scheduleIds.push(scheduleId);
3567535697
const init = this.visitValueBlock(terminal.init, terminal.loc);
35676-
const initBlock = this.cx.ir.blocks.get(init.block);
35677-
let initValue = init.value;
35678-
if (initValue.kind === 'SequenceExpression') {
35679-
const last = initBlock.instructions.at(-1);
35680-
initValue.instructions.push(last);
35681-
initValue.value = {
35682-
kind: 'Primitive',
35683-
value: undefined,
35684-
loc: terminal.loc,
35685-
};
35686-
}
35687-
else {
35688-
initValue = {
35689-
kind: 'SequenceExpression',
35690-
instructions: [initBlock.instructions.at(-1)],
35691-
id: terminal.id,
35692-
loc: terminal.loc,
35693-
value: {
35694-
kind: 'Primitive',
35695-
value: undefined,
35696-
loc: terminal.loc,
35697-
},
35698-
};
35699-
}
35698+
const initValue = this.valueBlockResultToSequence(init, terminal.loc);
3570035699
const testValue = this.visitValueBlock(terminal.test, terminal.loc).value;
3570135700
const updateValue = terminal.update !== null
3570235701
? this.visitValueBlock(terminal.update, terminal.loc).value
@@ -35741,55 +35740,9 @@ class Driver {
3574135740
const scheduleId = this.cx.scheduleLoop(terminal.fallthrough, terminal.init, terminal.loop);
3574235741
scheduleIds.push(scheduleId);
3574335742
const init = this.visitValueBlock(terminal.init, terminal.loc);
35744-
const initBlock = this.cx.ir.blocks.get(init.block);
35745-
let initValue = init.value;
35746-
if (initValue.kind === 'SequenceExpression') {
35747-
const last = initBlock.instructions.at(-1);
35748-
initValue.instructions.push(last);
35749-
initValue.value = {
35750-
kind: 'Primitive',
35751-
value: undefined,
35752-
loc: terminal.loc,
35753-
};
35754-
}
35755-
else {
35756-
initValue = {
35757-
kind: 'SequenceExpression',
35758-
instructions: [initBlock.instructions.at(-1)],
35759-
id: terminal.id,
35760-
loc: terminal.loc,
35761-
value: {
35762-
kind: 'Primitive',
35763-
value: undefined,
35764-
loc: terminal.loc,
35765-
},
35766-
};
35767-
}
35743+
const initValue = this.valueBlockResultToSequence(init, terminal.loc);
3576835744
const test = this.visitValueBlock(terminal.test, terminal.loc);
35769-
const testBlock = this.cx.ir.blocks.get(test.block);
35770-
let testValue = test.value;
35771-
if (testValue.kind === 'SequenceExpression') {
35772-
const last = testBlock.instructions.at(-1);
35773-
testValue.instructions.push(last);
35774-
testValue.value = {
35775-
kind: 'Primitive',
35776-
value: undefined,
35777-
loc: terminal.loc,
35778-
};
35779-
}
35780-
else {
35781-
testValue = {
35782-
kind: 'SequenceExpression',
35783-
instructions: [testBlock.instructions.at(-1)],
35784-
id: terminal.id,
35785-
loc: terminal.loc,
35786-
value: {
35787-
kind: 'Primitive',
35788-
value: undefined,
35789-
loc: terminal.loc,
35790-
},
35791-
};
35792-
}
35745+
const testValue = this.valueBlockResultToSequence(test, terminal.loc);
3579335746
let loopBody;
3579435747
if (loopId) {
3579535748
loopBody = this.traverseBlock(this.cx.ir.blocks.get(loopId));
@@ -35829,30 +35782,7 @@ class Driver {
3582935782
const scheduleId = this.cx.scheduleLoop(terminal.fallthrough, terminal.init, terminal.loop);
3583035783
scheduleIds.push(scheduleId);
3583135784
const init = this.visitValueBlock(terminal.init, terminal.loc);
35832-
const initBlock = this.cx.ir.blocks.get(init.block);
35833-
let initValue = init.value;
35834-
if (initValue.kind === 'SequenceExpression') {
35835-
const last = initBlock.instructions.at(-1);
35836-
initValue.instructions.push(last);
35837-
initValue.value = {
35838-
kind: 'Primitive',
35839-
value: undefined,
35840-
loc: terminal.loc,
35841-
};
35842-
}
35843-
else {
35844-
initValue = {
35845-
kind: 'SequenceExpression',
35846-
instructions: [initBlock.instructions.at(-1)],
35847-
id: terminal.id,
35848-
loc: terminal.loc,
35849-
value: {
35850-
kind: 'Primitive',
35851-
value: undefined,
35852-
loc: terminal.loc,
35853-
},
35854-
};
35855-
}
35785+
const initValue = this.valueBlockResultToSequence(init, terminal.loc);
3585635786
let loopBody;
3585735787
if (loopId) {
3585835788
loopBody = this.traverseBlock(this.cx.ir.blocks.get(loopId));
@@ -39721,7 +39651,7 @@ function inferBlock(context, state, block) {
3972139651
if (terminal.kind === 'try' && terminal.handlerBinding != null) {
3972239652
context.catchHandlers.set(terminal.handler, terminal.handlerBinding);
3972339653
}
39724-
else if (terminal.kind === 'maybe-throw') {
39654+
else if (terminal.kind === 'maybe-throw' && terminal.handler !== null) {
3972539655
const handlerParam = context.catchHandlers.get(terminal.handler);
3972639656
if (handlerParam != null) {
3972739657
CompilerError.invariant(state.kind(handlerParam) != null, {

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
748ee74e22ab86994c12564a19fc73950d00ad72
1+
3ce1316b05968d2a8cffe42a110f2726f2c44c3e
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
748ee74e22ab86994c12564a19fc73950d00ad72
1+
3ce1316b05968d2a8cffe42a110f2726f2c44c3e

compiled/facebook-www/React-dev.classic.js

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -537,33 +537,29 @@ __DEV__ &&
537537
function lazyInitializer(payload) {
538538
if (-1 === payload._status) {
539539
var resolveDebugValue = null,
540-
rejectDebugValue = null;
541-
if (enableAsyncDebugInfo) {
542-
var ioInfo = payload._ioInfo;
543-
null != ioInfo &&
544-
((ioInfo.start = ioInfo.end = performance.now()),
545-
(ioInfo.value = new Promise(function (resolve, reject) {
546-
resolveDebugValue = resolve;
547-
rejectDebugValue = reject;
548-
})));
549-
}
540+
rejectDebugValue = null,
541+
ioInfo = payload._ioInfo;
542+
null != ioInfo &&
543+
((ioInfo.start = ioInfo.end = performance.now()),
544+
(ioInfo.value = new Promise(function (resolve, reject) {
545+
resolveDebugValue = resolve;
546+
rejectDebugValue = reject;
547+
})));
550548
ioInfo = payload._result;
551549
var thenable = ioInfo();
552550
thenable.then(
553551
function (moduleObject) {
554552
if (0 === payload._status || -1 === payload._status) {
555553
payload._status = 1;
556554
payload._result = moduleObject;
557-
if (enableAsyncDebugInfo) {
558-
var _ioInfo = payload._ioInfo;
559-
if (null != _ioInfo) {
560-
_ioInfo.end = performance.now();
561-
var debugValue =
562-
null == moduleObject ? void 0 : moduleObject.default;
563-
resolveDebugValue(debugValue);
564-
_ioInfo.value.status = "fulfilled";
565-
_ioInfo.value.value = debugValue;
566-
}
555+
var _ioInfo = payload._ioInfo;
556+
if (null != _ioInfo) {
557+
_ioInfo.end = performance.now();
558+
var debugValue =
559+
null == moduleObject ? void 0 : moduleObject.default;
560+
resolveDebugValue(debugValue);
561+
_ioInfo.value.status = "fulfilled";
562+
_ioInfo.value.value = debugValue;
567563
}
568564
void 0 === thenable.status &&
569565
((thenable.status = "fulfilled"),
@@ -574,24 +570,20 @@ __DEV__ &&
574570
if (0 === payload._status || -1 === payload._status) {
575571
payload._status = 2;
576572
payload._result = error;
577-
if (enableAsyncDebugInfo) {
578-
var _ioInfo2 = payload._ioInfo;
579-
null != _ioInfo2 &&
580-
((_ioInfo2.end = performance.now()),
581-
_ioInfo2.value.then(noop, noop),
582-
rejectDebugValue(error),
583-
(_ioInfo2.value.status = "rejected"),
584-
(_ioInfo2.value.reason = error));
585-
}
573+
var _ioInfo2 = payload._ioInfo;
574+
null != _ioInfo2 &&
575+
((_ioInfo2.end = performance.now()),
576+
_ioInfo2.value.then(noop, noop),
577+
rejectDebugValue(error),
578+
(_ioInfo2.value.status = "rejected"),
579+
(_ioInfo2.value.reason = error));
586580
void 0 === thenable.status &&
587581
((thenable.status = "rejected"), (thenable.reason = error));
588582
}
589583
}
590584
);
591-
if (
592-
enableAsyncDebugInfo &&
593-
((ioInfo = payload._ioInfo), null != ioInfo)
594-
) {
585+
ioInfo = payload._ioInfo;
586+
if (null != ioInfo) {
595587
var displayName = thenable.displayName;
596588
"string" === typeof displayName && (ioInfo.name = displayName);
597589
}
@@ -854,7 +846,6 @@ __DEV__ &&
854846
deprecatedAPIs = require("ReactFeatureFlags");
855847
var enableTransitionTracing = deprecatedAPIs.enableTransitionTracing,
856848
enableViewTransition = deprecatedAPIs.enableViewTransition,
857-
enableAsyncDebugInfo = deprecatedAPIs.enableAsyncDebugInfo,
858849
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
859850
ReactSharedInternals = {
860851
H: null,
@@ -1344,12 +1335,11 @@ __DEV__ &&
13441335
exports.lazy = function (ctor) {
13451336
ctor = { _status: -1, _result: ctor };
13461337
var lazyType = {
1347-
$$typeof: REACT_LAZY_TYPE,
1348-
_payload: ctor,
1349-
_init: lazyInitializer
1350-
};
1351-
if (enableAsyncDebugInfo) {
1352-
var ioInfo = {
1338+
$$typeof: REACT_LAZY_TYPE,
1339+
_payload: ctor,
1340+
_init: lazyInitializer
1341+
},
1342+
ioInfo = {
13531343
name: "lazy",
13541344
start: -1,
13551345
end: -1,
@@ -1358,9 +1348,8 @@ __DEV__ &&
13581348
debugStack: Error("react-stack-top-frame"),
13591349
debugTask: console.createTask ? console.createTask("lazy()") : null
13601350
};
1361-
ctor._ioInfo = ioInfo;
1362-
lazyType._debugInfo = [{ awaited: ioInfo }];
1363-
}
1351+
ctor._ioInfo = ioInfo;
1352+
lazyType._debugInfo = [{ awaited: ioInfo }];
13641353
return lazyType;
13651354
};
13661355
exports.memo = function (type, compare) {
@@ -1493,7 +1482,7 @@ __DEV__ &&
14931482
exports.useTransition = function () {
14941483
return resolveDispatcher().useTransition();
14951484
};
1496-
exports.version = "19.3.0-www-classic-748ee74e-20260203";
1485+
exports.version = "19.3.0-www-classic-3ce1316b-20260203";
14971486
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14981487
"function" ===
14991488
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)