-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module Federation Share should support layers/issuerLayer #18988
Comments
@alexander-akait How does one specify the layer of a module? In consumeSharedModule - see it technically supports layer
However most loaders use Here is an example config i was working with to try and find a solution to this: const { ConsumeSharedPlugin } = require('../../../../dist/src');
module.exports = {
mode: 'development',
devtool: false,
entry: {
main: {
import: './index.js',
layer: 'entry-layer',
},
},
experiments: {
layers: true,
},
module: {
rules: [
{
test: /\.js$/,
issuerLayer: 'entry-layer',
layer: 'loader-layer', //react module will not have loader layer transforms
},
{
test: /react/,
issuerLayer: 'entry-layer', // would work if this were commented out
layer: 'react-layer',
},
],
},
plugins: [
new ConsumeSharedPlugin({
consumes: {
react: {
singleton: true,
},
rscreact: {
import: 'react',
singleton: true,
layer: 'loader-layer', // or should it be issuerLayer?
},
},
}),
],
}; Ideally it should just add all used "react" modules automatically instead of having to specify it, so if i import react, then somewhere else i import react with an issuerlayer, there would be 2 modules (react-layer)./react.js and ./react.js |
I see what you are trying to solve, pr welcome, I have not studied in detail how to do it better, so I am ready to consider your solution |
@alexander-akait can you add me as friend on discord so we can DM? I am unable to DM directly but it would be helpful to corrospond back and forth in chat around this area. I found that Module accepts super(a,b,layer) so I can set layer in module factory. However I do not know if there is way to set issuerLayer as well. So that module would behave as if it was from issuerlayer too. |
can you explain me more in details for this issue |
Feature request
Loader layers currently have no convention for support when using something like issueLayer, for example with RSC
What is the expected behavior?
There should be a convention to specify or auto assign the layers used when creating the shares
What is motivation or use case for adding/changing the behavior?
RSC support likely will need loader layers or layers to work
How should this be implemented in your opinion?
Unsure but i think it needs to be cone at ConsumeShared and ProvideShared, either in the hooks or in the Module classes of these - but i do not know
Are you willing to work on this yourself?
yes
The text was updated successfully, but these errors were encountered: