From 62c3404ce2c1d074e75ab6cf455a47ace7885fd0 Mon Sep 17 00:00:00 2001 From: Sean Parsons <217400+seanparsons@users.noreply.github.com> Date: Tue, 9 Jul 2024 11:10:12 +0100 Subject: [PATCH] fix(remix) Expand valid Remix cases for route modules. (#6042) - 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. --- editor/src/core/model/project-file-utils.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/editor/src/core/model/project-file-utils.ts b/editor/src/core/model/project-file-utils.ts index 16df15e6eb73..b7169de1abef 100644 --- a/editor/src/core/model/project-file-utils.ts +++ b/editor/src/core/model/project-file-utils.ts @@ -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 || @@ -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 } }