Skip to content

Commit

Permalink
Update on "compiler: fixtures for fast-refresh mode (w todos)"
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
josephsavona committed May 20, 2024
1 parent 33fe142 commit 70ce864
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function codegenFunction(
* If HMR detection is enabled and we know the source code of the component, assign a cache slot to track
* the source hash, and later, emit code to check for source changes and reset the cache on source changes.
*/
let fasthRefreshResetState: {
let fastRefreshState: {
cacheIndex: number;
hash: string;
} | null = null;
Expand All @@ -95,7 +95,7 @@ export function codegenFunction(
fn.env.code !== null
) {
const hash = createHmac("sha256", fn.env.code).digest("hex");
fasthRefreshResetState = {
fastRefreshState = {
cacheIndex: cx.nextCacheIndex,
hash,
};
Expand Down Expand Up @@ -134,7 +134,7 @@ export function codegenFunction(
),
])
);
if (fasthRefreshResetState !== null) {
if (fastRefreshState !== null) {
// HMR detection is enabled, emit code to reset the memo cache on source changes
const index = cx.synthesizeName("$i");
preface.push(
Expand All @@ -143,10 +143,10 @@ export function codegenFunction(
"!==",
t.memberExpression(
t.identifier(cx.synthesizeName("$")),
t.numericLiteral(fasthRefreshResetState.cacheIndex),
t.numericLiteral(fastRefreshState.cacheIndex),
true
),
t.stringLiteral(fasthRefreshResetState.hash)
t.stringLiteral(fastRefreshState.hash)
),
t.blockStatement([
t.forStatement(
Expand Down Expand Up @@ -188,10 +188,10 @@ export function codegenFunction(
"=",
t.memberExpression(
t.identifier(cx.synthesizeName("$")),
t.numericLiteral(fasthRefreshResetState.cacheIndex),
t.numericLiteral(fastRefreshState.cacheIndex),
true
),
t.stringLiteral(fasthRefreshResetState.hash)
t.stringLiteral(fastRefreshState.hash)
)
),
])
Expand Down

0 comments on commit 70ce864

Please sign in to comment.