Skip to content

Commit 9ecfe30

Browse files
committed
fix(laroux): improve handling of undefined values in logging and JSR resolver plugin
- Updated log level mapping to use constants from the logging module for better clarity and maintainability. - Changed return values in JSR resolver plugin to return empty objects instead of undefined for improved error handling. - Added safety checks in RSC rewrite imports to prevent processing errors when accessing string literals.
1 parent 65deeac commit 9ecfe30

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

pkg/@eser/cli/commands/laroux/build.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,14 @@ export const buildHandler = async (ctx: CommandContext): Promise<void> => {
4747
const { runtime } = await import("@eser/standards/runtime");
4848

4949
// Map log level names to @eser/logging severity values
50-
// See logging.Severities: Trace=1, Debug=5, Info=9, Warning=13, Error=17, Critical=21
51-
const logLevelMap: Record<LogLevel, number> = {
52-
trace: 1, // Severities.Trace
53-
debug: 5, // Severities.Debug
54-
info: 9, // Severities.Info
55-
warn: 13, // Severities.Warning
56-
error: 17, // Severities.Error
57-
fatal: 21, // Severities.Critical
58-
};
50+
const logLevelMap = {
51+
trace: logging.Severities.Trace,
52+
debug: logging.Severities.Debug,
53+
info: logging.Severities.Info,
54+
warn: logging.Severities.Warning,
55+
error: logging.Severities.Error,
56+
fatal: logging.Severities.Critical,
57+
} as const;
5958

6059
await logging.config.configure({
6160
sinks: {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ function isInsideStringLiteral(content: string, position: number): boolean {
3232
for (let i = 0; i < position; i++) {
3333
const char = content[i];
3434

35+
// Safety check (shouldn't happen since i < position <= content.length)
36+
if (char === undefined) {
37+
break;
38+
}
39+
3540
// Skip escaped quotes
3641
if (prevChar === "\\") {
3742
prevChar = char;

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 undefined; // Let other resolvers handle it
81+
return {}; // 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 undefined;
110+
return {}; // Let other loaders handle it
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 undefined;
143+
return {}; // Let other resolvers handle it
144144
}
145145
});
146146
},

0 commit comments

Comments
 (0)