Skip to content

fix: Skip dirs with .js extensions #509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/src/lib/getSrcPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export async function getSrcPaths(
const files = await glob(globPattern, {
ignore: ["**/node_modules/**", "**/dist/**", "**/*.d.ts"],
absolute: true,
nodir: true,
});
return files;
} catch (error) {
Expand Down
9 changes: 9 additions & 0 deletions sdk/src/vite/createDirectiveLookupPlugin.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import debug from "debug";
import { normalizeModulePath } from "./normalizeModulePath.mjs";
import { ensureAliasArray } from "./ensureAliasArray.mjs";
import { pathExists } from "fs-extra";
import { stat } from "fs/promises";
import { getSrcPaths } from "../lib/getSrcPaths.js";

interface DirectiveLookupConfig {
Expand Down Expand Up @@ -44,6 +45,7 @@ export const findFilesContainingDirective = async ({
{
cwd: projectRootDir,
absolute: true,
nodir: true,
},
);

Expand All @@ -53,6 +55,13 @@ export const findFilesContainingDirective = async ({

for (const file of allFiles) {
try {
const stats = await stat(file);

if (!stats.isFile()) {
verboseLog("Skipping %s (not a file)", file);
continue;
}

verboseLog("Scanning file: %s", file);
const content = await readFile(file, "utf-8");
const lines = content.split("\n");
Expand Down