From e1b002c2ecdd35d0346a591132423109eb619183 Mon Sep 17 00:00:00 2001 From: Harrison Hogg Date: Mon, 16 Sep 2024 12:48:03 +0100 Subject: [PATCH] Don't fail publishing on default feature detection Signed-off-by: Harrison Hogg --- packages/cli/src/lib/typeDistProject.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/cli/src/lib/typeDistProject.ts b/packages/cli/src/lib/typeDistProject.ts index 24e7affcfe..6845272433 100644 --- a/packages/cli/src/lib/typeDistProject.ts +++ b/packages/cli/src/lib/typeDistProject.ts @@ -158,12 +158,19 @@ export const getEntryPointDefaultFeatureType = ( entryPoint.path.replace(entryPoint.ext, '.d.ts'), ); - const defaultFeatureType = getSourceFileDefaultFeatureType( - project.addSourceFileAtPath(dtsPath), - ); + try { + const defaultFeatureType = getSourceFileDefaultFeatureType( + project.addSourceFileAtPath(dtsPath), + ); - if (defaultFeatureType) { - return defaultFeatureType; + if (defaultFeatureType) { + return defaultFeatureType; + } + } catch (error) { + console.error( + `Failed to extract default feature type from ${dtsPath}, ${error}. ` + + 'Your package will publish fine but it may be missing metadata about its default feature.', + ); } }