Skip to content

Commit

Permalink
fix(remix) Expand valid Remix cases for route modules. (#6042)
Browse files Browse the repository at this point in the history
- Change `getDefaultExportNameAndUidFromFile` to optionally return a
uid. Permitting a file that exists with a default export to be included
if it doesn't have a `UTOPIA_JSX_COMPONENT` matching that export.
  • Loading branch information
seanparsons authored Jul 9, 2024
1 parent 8b7dd1d commit 62c3404
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions editor/src/core/model/project-file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ export function getDefaultExportedTopLevelElement(file: TextFile): JSXElementChi
export function getDefaultExportNameAndUidFromFile(
projectContents: ProjectContentTreeRoot,
filePath: string,
): { name: string; uid: string } | null {
): { name: string; uid: string | null } | null {
const file = getProjectFileByFilePath(projectContents, filePath)
if (
file == null ||
Expand All @@ -877,13 +877,11 @@ export function getDefaultExportNameAndUidFromFile(
return null
}

const elementUid = file.fileContents.parsed.topLevelElements.find(
(t): t is UtopiaJSXComponent =>
t.type === 'UTOPIA_JSX_COMPONENT' && t.name === defaultExportName,
)?.rootElement.uid
if (elementUid == null) {
return null
}
const elementUid =
file.fileContents.parsed.topLevelElements.find(
(t): t is UtopiaJSXComponent =>
t.type === 'UTOPIA_JSX_COMPONENT' && t.name === defaultExportName,
)?.rootElement.uid ?? null

return { name: defaultExportName, uid: elementUid }
}
Expand Down

0 comments on commit 62c3404

Please sign in to comment.