From 8f67e72b6f4f663c0dc799821332b0e58059f335 Mon Sep 17 00:00:00 2001 From: thejackshelton Date: Sat, 11 Jan 2025 18:17:41 -0600 Subject: [PATCH 1/3] feat: handle barrel files --- libs/qwikdev-astro/src/index.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/libs/qwikdev-astro/src/index.ts b/libs/qwikdev-astro/src/index.ts index 84a1faa..4d6d6b8 100644 --- a/libs/qwikdev-astro/src/index.ts +++ b/libs/qwikdev-astro/src/index.ts @@ -134,11 +134,10 @@ export default defineIntegration({ resolveEntrypoints(); }, async resolveId(id, importer) { - // only grab the imports of Astro files - const isAstroFile = - importer?.endsWith(".astro") || importer?.endsWith(".mdx"); - - if (!isAstroFile) { + const isFromAstro = importer?.endsWith('.astro') || importer?.endsWith('.mdx'); + const isFromTrackedFile = potentialEntries.has(importer ?? ''); + + if (!isFromAstro && !isFromTrackedFile) { return null; } @@ -147,18 +146,12 @@ export default defineIntegration({ throw new Error(`Could not resolve ${id} from ${importer}`); } - const isPotentialEntry = /\.(tsx|jsx|ts|js|qwik\.)/.test(resolved.id); - if (!isPotentialEntry) { - return null; - } - - // add Qwik libraries if (resolved.id.includes(".qwik.")) { qwikEntrypoints.add(resolved.id); - } else { - potentialEntries.add(resolved.id); + return null; } + potentialEntries.add(resolved.id); return null; }, async transform(code, id) { From e33e85a9589be78662ef84a238e29fb1a7d2a844 Mon Sep 17 00:00:00 2001 From: thejackshelton Date: Sat, 11 Jan 2025 18:20:32 -0600 Subject: [PATCH 2/3] remove comment since actually faster --- libs/qwikdev-astro/src/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/libs/qwikdev-astro/src/index.ts b/libs/qwikdev-astro/src/index.ts index 4d6d6b8..41b2f72 100644 --- a/libs/qwikdev-astro/src/index.ts +++ b/libs/qwikdev-astro/src/index.ts @@ -167,8 +167,6 @@ export default defineIntegration({ * @qwik.dev/core * @qwik.dev/react */ - - // TODO: use parser here (vite gives it) const qwikImportsRegex = /@builder\.io\/qwik(-react)?|qwik\.dev\/(core|react)/; From e6621dc4af8ce134ca105550627b10cf5b87995b Mon Sep 17 00:00:00 2001 From: thejackshelton Date: Sat, 11 Jan 2025 18:22:51 -0600 Subject: [PATCH 3/3] changeset --- .changeset/thin-coats-help.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/thin-coats-help.md diff --git a/.changeset/thin-coats-help.md b/.changeset/thin-coats-help.md new file mode 100644 index 0000000..280943a --- /dev/null +++ b/.changeset/thin-coats-help.md @@ -0,0 +1,5 @@ +--- +"@qwikdev/astro": patch +--- + +fix: efficiently scan barrel files