Skip to content

Commit c6e6567

Browse files
justin808claude
andcommitted
fix: Show actual character count in debug logging
Changed component size reporting from kilobytes (size/1024) to actual character count. This is more accurate and useful for developers debugging component registration. Before: "~1.5 chars" (actually KB) After: "342 chars" (actual character count) Updated tests to match the new format. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 743ba6c commit c6e6567

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/react-on-rails/src/base/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Fix: Use only react-on-rails OR react-on-rails-pro, not both.`);
205205
componentNames.forEach((name) => {
206206
const component = components[name];
207207
const size = component.toString().length;
208-
console.log(`[ReactOnRails] ✅ Registered: ${name} (~${(size / 1024).toFixed(1)} chars)`);
208+
console.log(`[ReactOnRails] ✅ Registered: ${name} (${size} chars)`);
209209
});
210210
}
211211
} else {

packages/react-on-rails/tests/debugLogging.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ describe('Debug Logging', () => {
101101
expect.stringMatching(/\[ReactOnRails\] Component registration completed in \d+\.\d+ms/),
102102
);
103103
expect(consoleLogSpy).toHaveBeenCalledWith(
104-
expect.stringMatching(/\[ReactOnRails\] Registered: TestComponent \(~\d+\.\d+ chars\)/),
104+
expect.stringMatching(/\[ReactOnRails\] Registered: TestComponent \(\d+ chars\)/),
105105
);
106106
});
107107

@@ -120,10 +120,10 @@ describe('Debug Logging', () => {
120120

121121
// Check that individual component registrations are logged with size info
122122
expect(consoleLogSpy).toHaveBeenCalledWith(
123-
expect.stringMatching(/\[ReactOnRails\] Registered: SmallComponent \(~\d+\.\d+ chars\)/),
123+
expect.stringMatching(/\[ReactOnRails\] Registered: SmallComponent \(\d+ chars\)/),
124124
);
125125
expect(consoleLogSpy).toHaveBeenCalledWith(
126-
expect.stringMatching(/\[ReactOnRails\] Registered: LargerComponent \(~\d+\.\d+ chars\)/),
126+
expect.stringMatching(/\[ReactOnRails\] Registered: LargerComponent \(\d+ chars\)/),
127127
);
128128
});
129129

@@ -144,7 +144,7 @@ describe('Debug Logging', () => {
144144
expect.stringMatching(/\[ReactOnRails\] Component registration completed in \d+\.\d+ms/),
145145
);
146146
expect(consoleLogSpy).toHaveBeenCalledWith(
147-
expect.stringMatching(/\[ReactOnRails\] Registered: TestComponent \(~\d+\.\d+ chars\)/),
147+
expect.stringMatching(/\[ReactOnRails\] Registered: TestComponent \(\d+ chars\)/),
148148
);
149149
});
150150
});

0 commit comments

Comments
 (0)