Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
fix: All fixes to build cypress' real world app (#25)
Browse files Browse the repository at this point in the history
* fix: All fixes to build cypress' real world app

* Add changeset
  • Loading branch information
mohebifar authored Mar 9, 2024
1 parent f887b88 commit 5c3b26a
Show file tree
Hide file tree
Showing 36 changed files with 1,033 additions and 631 deletions.
6 changes: 6 additions & 0 deletions .changeset/strong-donkeys-guess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@react-unforget/babel-plugin": minor
"@react-unforget/runtime": minor
---

Fix issues with JSX unwrapping, alias analysis, and conditional JSX expressions
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
4 changes: 2 additions & 2 deletions apps/docs/components/LiveCodeSandpack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function LiveCodeSandpack({ children, previewClassName }: LiveCodeProps) {
code: beforeCode,
},
}),
[beforeCode]
[beforeCode],
);

const afterFiles = useMemo(
Expand All @@ -79,7 +79,7 @@ function LiveCodeSandpack({ children, previewClassName }: LiveCodeProps) {
code: afterCode,
},
}),
[afterCode]
[afterCode],
);

return (
Expand Down
18 changes: 9 additions & 9 deletions packages/babel-plugin/src/models/Component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export class Component {
path.assertFunction();

this.cacheValueIdentifier = path.scope.generateUidIdentifier(
DEFAULT_CACHE_VARIABLE_NAME
DEFAULT_CACHE_VARIABLE_NAME,
);

this.cacheCommitIdentifier = path.scope.generateUidIdentifier(
DEFAULT_CACHE_COMMIT_VARIABLE_NAME
DEFAULT_CACHE_COMMIT_VARIABLE_NAME,
);

this.cacheNullIdentifier = path.scope.generateUidIdentifier(
DEFAULT_CACHE_NULL_VARIABLE_NAME
DEFAULT_CACHE_NULL_VARIABLE_NAME,
);

this.init();
Expand Down Expand Up @@ -97,7 +97,7 @@ export class Component {
]),
t.callExpression(t.identifier(RUNTIME_MODULE_CREATE_CACHE_HOOK_NAME), [
sizeNumber,
])
]),
),
]);

Expand All @@ -110,7 +110,7 @@ export class Component {
return `${id} => ${name}`;
})
.join("\n") +
"\n"
"\n",
);

return declaration;
Expand All @@ -125,7 +125,7 @@ export class Component {
}

createComponentSegment(
segmentPath: babel.NodePath<t.Node>
segmentPath: babel.NodePath<t.Node>,
): ComponentSegment {
if (this.segmentsMap.has(segmentPath)) {
return this.segmentsMap.get(segmentPath)!;
Expand All @@ -143,13 +143,13 @@ export class Component {
}

findPotentialParentForSegment(
path: babel.NodePath<babel.types.Node>
path: babel.NodePath<babel.types.Node>,
): ComponentSegment | null {
const blockOrControlFlowStatement = path.findParent(
(innerPath) =>
(innerPath.isBlockStatement() || isControlFlowStatement(innerPath)) &&
innerPath.isDescendant(this.path) &&
isInTheSameFunctionScope(innerPath, this.path)
isInTheSameFunctionScope(innerPath, this.path),
) as babel.NodePath<babel.types.BlockStatement> | null;

if (!blockOrControlFlowStatement) {
Expand Down Expand Up @@ -184,7 +184,7 @@ export class Component {

getDependentsOfSegment(segment: ComponentSegment) {
return Array.from(this.segmentsMap.values()).filter((s) =>
s.hasDirectDependencyOn(segment)
s.hasDirectDependencyOn(segment),
);
}

Expand Down
Loading

0 comments on commit 5c3b26a

Please sign in to comment.