Skip to content

Commit 8a8db73

Browse files
test(enhanced): add singleton+version warning case for aliasConsumption
New ConfigCase share-with-aliases-filters-singleton exercises singleton with include.version under aliasConsumption; asserts warnings.
1 parent 4c4c349 commit 8a8db73

File tree

7 files changed

+82
-0
lines changed

7 files changed

+82
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// No build errors expected
2+
module.exports = [];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
it('should warn when singleton is combined with include.version for alias-resolved share', async () => {
2+
const viaAlias = await import('react-allowed');
3+
const direct = await import('next/dist/compiled/react-allowed');
4+
5+
// Shared identity should match direct
6+
expect(viaAlias.name).toBe(direct.name);
7+
expect(viaAlias.source).toBe(direct.source);
8+
});
9+
10+
module.exports = {
11+
testName: 'share-with-aliases-filters-singleton',
12+
};

packages/enhanced/test/configCases/sharing/share-with-aliases-filters-singleton/node_modules/next/dist/compiled/react-allowed.js

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/enhanced/test/configCases/sharing/share-with-aliases-filters-singleton/node_modules/next/package.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "test-share-with-aliases-filters-singleton",
3+
"version": "1.0.0"
4+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Expect singleton + include.version warning
2+
module.exports = [
3+
// ProvideSharedPlugin warnings (emitted twice: provide and finalize)
4+
{
5+
file: /shared module next\/dist\/compiled\/react-allowed .*->.*react-allowed\.js/,
6+
message:
7+
/\"singleton: true\" is used together with \"include\.version: \"\^18\.0\.0\"\"/,
8+
},
9+
{
10+
file: /shared module next\/dist\/compiled\/react-allowed .*->.*react-allowed\.js/,
11+
message:
12+
/\"singleton: true\" is used together with \"include\.version: \"\^18\.0\.0\"\"/,
13+
},
14+
// ConsumeSharedPlugin warning (moduleRequest is absolute resource path)
15+
{
16+
file: /shared module .*react-allowed\.js .*->.*react-allowed\.js/,
17+
message:
18+
/\"singleton: true\" is used together with \"include\.version: \"\^18\.0\.0\"\"/,
19+
},
20+
];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { ModuleFederationPlugin } = require('../../../../dist/src');
2+
const path = require('path');
3+
4+
module.exports = {
5+
mode: 'development',
6+
devtool: false,
7+
resolve: {
8+
alias: {
9+
'react-allowed': path.resolve(
10+
__dirname,
11+
'node_modules/next/dist/compiled/react-allowed.js',
12+
),
13+
},
14+
},
15+
plugins: [
16+
new ModuleFederationPlugin({
17+
name: 'share-with-aliases-filters-singleton',
18+
experiments: { asyncStartup: false, aliasConsumption: true },
19+
shared: {
20+
// Include + singleton: expect singleton+filter warning
21+
'next/dist/compiled/react-allowed': {
22+
import: 'next/dist/compiled/react-allowed',
23+
requiredVersion: false,
24+
singleton: true,
25+
include: { version: '^18.0.0' },
26+
},
27+
},
28+
}),
29+
],
30+
};

0 commit comments

Comments
 (0)