From 208d697c0822c8eb9ddee20bf11985ec464fc947 Mon Sep 17 00:00:00 2001 From: "Andrey Mikhaylov (lolmaus)" Date: Thu, 8 Feb 2024 16:25:00 +0300 Subject: [PATCH] Fix telemetry consumption: new components from @ember namespace --- .../angle-brackets/telemetry/invokable.js | 18 +++++++++++++++++- transforms/angle-brackets/transform.js | 17 +++++++---------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/transforms/angle-brackets/telemetry/invokable.js b/transforms/angle-brackets/telemetry/invokable.js index f80ceed48..663abd021 100644 --- a/transforms/angle-brackets/telemetry/invokable.js +++ b/transforms/angle-brackets/telemetry/invokable.js @@ -4,7 +4,23 @@ const HELPER = 'Helper'; const COMPONENT = 'Component'; function invokableName(name, type) { - let invokePath = type === HELPER ? '/helpers/' : '/components/'; + let invokePath; + + if (name.startsWith('@ember/component/')) { + invokePath = '@ember/component/'; + } else if (name.startsWith('@ember/routing/')) { + invokePath = '@ember/routing/'; + } else if (type === HELPER) { + invokePath = '/helpers/'; + } else { + invokePath = '/components/'; + } + + console.log({ + name, + invokePath, + result: name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length), + }); return name.substring(name.lastIndexOf(invokePath) + invokePath.length, name.length); } diff --git a/transforms/angle-brackets/transform.js b/transforms/angle-brackets/transform.js index 04eb5698a..18fbca425 100755 --- a/transforms/angle-brackets/transform.js +++ b/transforms/angle-brackets/transform.js @@ -349,13 +349,13 @@ function isKnownHelper(fullName, config, invokableData) { if (isComponent) { return false; } + } else { + let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])]; + let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name); + let isComponent = [...(components || []), ...BUILT_IN_COMPONENTS].includes(name); + let strName = `${name}`; // coerce boolean and number to string + return (isHelper || !isComponent) && !strName.includes('.'); } - - let mergedHelpers = [...KNOWN_HELPERS, ...(helpers || [])]; - let isHelper = mergedHelpers.includes(name) || config.helpers.includes(name); - let isComponent = [...(components || []), ...BUILT_IN_COMPONENTS].includes(name); - let strName = `${name}`; // coerce boolean and number to string - return (isHelper || (!config.unambiguousHelpers && !isComponent)) && !strName.includes('.'); } else { return KNOWN_HELPERS.includes(name) || config.helpers.includes(name); } @@ -483,10 +483,7 @@ function transformToAngleBracket(fileInfo, config, invokableData) { const isTagKnownHelper = isKnownHelper(tagName, config, invokableData); // Don't change attribute statements - const isValidMustacheComponent = config.unambiguousHelpers - ? node.loc.source !== '(synthetic)' && !isTagKnownHelper - : node.loc.source !== '(synthetic)' && !isKnownHelper(tagName, config, invokableData); - + const isValidMustacheComponent = node.loc.source !== '(synthetic)' && !isTagKnownHelper; const isNestedComponent = isNestedComponentTagName(tagName); if (