Skip to content

Commit

Permalink
feat: handle barrel files
Browse files Browse the repository at this point in the history
  • Loading branch information
thejackshelton committed Jan 12, 2025
1 parent e47aee9 commit 8f67e72
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions libs/qwikdev-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down

0 comments on commit 8f67e72

Please sign in to comment.