Skip to content

Commit

Permalink
Merge pull request #225 from QwikDev/handle-barrels
Browse files Browse the repository at this point in the history
Handle barrels
  • Loading branch information
thejackshelton authored Jan 12, 2025
2 parents e7c3394 + e6621dc commit 88562e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-coats-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@qwikdev/astro": patch
---

fix: efficiently scan barrel files
21 changes: 6 additions & 15 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 All @@ -174,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)/;

Expand Down

0 comments on commit 88562e6

Please sign in to comment.