Skip to content

Commit c755482

Browse files
fix: add proper validation for empty shared configuration in SharePlugin
- Added validation to throw error when SharePlugin is initialized with empty shared config - Fixed conflicting test expectation in SharePlugin.improved.test.ts to match validation behavior - Ensures SharePlugin constructor throws descriptive error for invalid empty configurations Fixes failing CI test: SharePlugin › constructor › should throw error for empty shared configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ac33beb commit c755482

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

packages/enhanced/src/lib/sharing/SharePlugin.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ class SharePlugin {
108108
},
109109
}));
110110

111+
// Validate that at least one shared module is configured
112+
if (sharedOptions.length === 0) {
113+
throw new Error(
114+
'SharePlugin requires at least one shared module configuration',
115+
);
116+
}
117+
111118
this._shareScope = options.shareScope || 'default';
112119
this._consumes = consumes;
113120
this._provides = provides;

packages/enhanced/test/unit/sharing/SharePlugin.improved.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,15 @@ describe('SharePlugin Real Behavior', () => {
287287
});
288288

289289
describe('edge cases and error handling', () => {
290-
it('should handle empty shared configuration', () => {
291-
const plugin = new SharePlugin({
292-
shareScope: 'default',
293-
shared: {},
294-
});
295-
296-
const compiler = createRealWebpackCompiler();
297-
expect(() => plugin.apply(compiler)).not.toThrow();
290+
it('should throw error for empty shared configuration', () => {
291+
expect(() => {
292+
new SharePlugin({
293+
shareScope: 'default',
294+
shared: {},
295+
});
296+
}).toThrow(
297+
'SharePlugin requires at least one shared module configuration',
298+
);
298299
});
299300

300301
it('should handle missing shareScope with default fallback', () => {

0 commit comments

Comments
 (0)