Skip to content

Commit 65deeac

Browse files
committed
fix(laroux): improve handling of undefined values in various functions
- Updated checks to handle undefined values instead of null in CSS module caching and JSR resolver plugin error handling. - Added a safeguard to skip processing when no import path is captured in the RSC rewrite imports. - Adjusted exports in middleware to reflect changes in rate limiter functionality.
1 parent 3691f6e commit 65deeac

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

pkg/@eser/laroux-bundler/adapters/react/rsc-rewrite-imports.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function parseImports(
7474
while ((match = importRegex.exec(content)) !== null) {
7575
const importPath = match[1];
7676

77+
// Skip if no import path captured
78+
if (!importPath) {
79+
continue;
80+
}
81+
7782
// Skip if this import is inside a string literal (e.g., code samples)
7883
if (isInsideStringLiteral(content, match.index)) {
7984
continue;

pkg/@eser/laroux-bundler/css-modules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ export async function processCSSModules(
142142
const fileMtime = fileStat.mtime?.getTime() ?? 0;
143143
const cached = cache.getCssModuleResult(cssPath, fileMtime);
144144

145-
if (cached !== undefined) {
145+
if (cached !== undefined && cached !== null) {
146146
cacheHits++;
147147
return [cssPath, {
148148
code: cached.code,

pkg/@eser/laroux-bundler/jsr-resolver-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function createJsrResolverPlugin(
7878
error instanceof Error ? error.message : String(error)
7979
}`,
8080
);
81-
return null; // Let other resolvers handle it
81+
return undefined; // Let other resolvers handle it
8282
}
8383
});
8484

@@ -107,7 +107,7 @@ export function createJsrResolverPlugin(
107107
if (contents !== undefined) {
108108
return { contents, loader: "js" };
109109
}
110-
return null;
110+
return undefined;
111111
});
112112

113113
// Match explicit jsr: specifiers
@@ -140,7 +140,7 @@ export function createJsrResolverPlugin(
140140
error instanceof Error ? error.message : String(error)
141141
}`,
142142
);
143-
return null;
143+
return undefined;
144144
}
145145
});
146146
},

pkg/@eser/laroux-server/runtime/middleware/mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
export {
88
createRateLimiter,
9-
getRateLimitHeaders,
9+
getClientIp,
1010
type RateLimitConfig,
11-
stopRateLimiter,
11+
type RateLimiterInstance,
1212
} from "@eser/http/middlewares/rate-limiter";

0 commit comments

Comments
 (0)