Skip to content

Commit 1fbe79b

Browse files
Merge branch 'pr9-implementation' into share-filter
2 parents 4d022a9 + 47e8eb0 commit 1fbe79b

File tree

7 files changed

+20
-57
lines changed

7 files changed

+20
-57
lines changed

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

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,7 @@ class SharePlugin {
5757
};
5858
return config;
5959
},
60-
(item, key) => {
61-
// Enhanced validation for shared config
62-
if (item.include && item.exclude) {
63-
throw new Error(
64-
`Cannot specify both include and exclude filters for shared module "${key}"`,
65-
);
66-
}
67-
return item;
68-
},
60+
(item) => item,
6961
);
7062
const consumes: Record<string, ConsumesConfig>[] = sharedOptions.map(
7163
([key, options]) => ({
@@ -184,27 +176,15 @@ class SharePlugin {
184176
process.env['FEDERATION_WEBPACK_PATH'] =
185177
process.env['FEDERATION_WEBPACK_PATH'] || getWebpackPath(compiler);
186178

187-
// Apply ConsumeSharedPlugin with enhanced error handling
188-
try {
189-
new ConsumeSharedPlugin({
190-
shareScope: this._shareScope,
191-
consumes: this._consumes,
192-
}).apply(compiler);
193-
} catch (error) {
194-
const message = error instanceof Error ? error.message : String(error);
195-
throw new Error(`Failed to apply ConsumeSharedPlugin: ${message}`);
196-
}
179+
new ConsumeSharedPlugin({
180+
shareScope: this._shareScope,
181+
consumes: this._consumes,
182+
}).apply(compiler);
197183

198-
// Apply ProvideSharedPlugin with enhanced error handling
199-
try {
200-
new ProvideSharedPlugin({
201-
shareScope: this._shareScope,
202-
provides: this._provides,
203-
}).apply(compiler);
204-
} catch (error) {
205-
const message = error instanceof Error ? error.message : String(error);
206-
throw new Error(`Failed to apply ProvideSharedPlugin: ${message}`);
207-
}
184+
new ProvideSharedPlugin({
185+
shareScope: this._shareScope,
186+
provides: this._provides,
187+
}).apply(compiler);
208188
}
209189
}
210190

packages/enhanced/test/compiler-unit/sharing/SharePlugin.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,7 @@ describe('SharePlugin Compiler Integration', () => {
273273
new SharePlugin({
274274
shared: {},
275275
});
276-
}).toThrow(
277-
'SharePlugin requires at least one shared module configuration',
278-
);
276+
}).not.toThrow();
279277

280278
expect(() => {
281279
new SharePlugin({
@@ -286,9 +284,7 @@ describe('SharePlugin Compiler Integration', () => {
286284
},
287285
},
288286
});
289-
}).toThrow(
290-
'Cannot specify both include and exclude filters for shared module "react"',
291-
);
287+
}).not.toThrow();
292288
});
293289
});
294290
});

packages/enhanced/test/configCases/sharing/consume-filters/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ module.exports = {
3737
},
3838
// Request filtering tests
3939
'components/': {
40-
shareKey: 'request-prefix',
40+
shareKey: 'request-prefix/',
4141
include: {
4242
request: /^Button/,
4343
},

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

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

289289
describe('edge cases and error handling', () => {
290-
it('should throw error for empty shared configuration', () => {
290+
it('should handle empty shared configuration', () => {
291291
expect(() => {
292292
new SharePlugin({
293293
shareScope: 'default',
294294
shared: {},
295295
});
296-
}).toThrow(
297-
'SharePlugin requires at least one shared module configuration',
298-
);
296+
}).not.toThrow();
299297
});
300298

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

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,15 @@ const SharePlugin = require('../../../src/lib/sharing/SharePlugin').default;
4444

4545
describe('SharePlugin', () => {
4646
describe('constructor', () => {
47-
it('should throw error for empty shared configuration', () => {
47+
it('should handle empty shared configuration', () => {
4848
expect(() => {
4949
new SharePlugin({
5050
shared: {},
5151
});
52-
}).toThrow(
53-
'SharePlugin requires at least one shared module configuration',
54-
);
52+
}).not.toThrow();
5553
});
5654

57-
it('should throw error for conflicting include/exclude filters', () => {
55+
it('should allow both include and exclude filters together', () => {
5856
expect(() => {
5957
new SharePlugin({
6058
shared: {
@@ -64,9 +62,7 @@ describe('SharePlugin', () => {
6462
},
6563
},
6664
});
67-
}).toThrow(
68-
'Cannot specify both include and exclude filters for shared module "react"',
69-
);
65+
}).not.toThrow();
7066
});
7167

7268
it('should initialize with string shareScope', () => {

packages/modernjs/src/constant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const LOCALHOST = 'localhost';
22
export const PLUGIN_IDENTIFIER = '[ Modern.js Module Federation ]';
3-
// Force rebuild - CI fix attempt
3+

packages/rsbuild-plugin/tsconfig.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,7 @@
1515
"skipDefaultLibCheck": true,
1616
"declaration": true,
1717
"noImplicitAny": false,
18-
"paths": {
19-
"@module-federation/sdk": ["../sdk/src/index.ts"],
20-
"@module-federation/sdk/*": ["../sdk/src/*"],
21-
"@module-federation/enhanced": ["../enhanced/src/index.ts"],
22-
"@module-federation/enhanced/*": ["../enhanced/src/*"],
23-
"@module-federation/node": ["../node/src/index.ts"],
24-
"@module-federation/node/*": ["../node/src/*"]
25-
}
18+
2619
},
2720
"include": ["src", "../../global.d.ts", "__tests__/**/*"],
2821
"exclude": [

0 commit comments

Comments
 (0)