Skip to content
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

Entry runtime miss function "O" #2747

Open
5 tasks done
lecion opened this issue Jul 10, 2024 · 6 comments
Open
5 tasks done

Entry runtime miss function "O" #2747

lecion opened this issue Jul 10, 2024 · 6 comments

Comments

@lecion
Copy link

lecion commented Jul 10, 2024

Describe the bug

As you can see the picture below, e.O is undefined.

image

Background

I have two Module Federation projects:

  • MfBase: Acts as both provider and consumer. It provides common capabilities, such as utilities and APIs, and consumes the routes exposed by MfOrderCloud.
  • MfOrderCloud: Also a provider and consumer. This project handles some e-commerce order business. It provides its own routes to MfBase and consumes the codebase from MfBase.

When I use WebpackModuleFederationPlugin, everything works fine. However, it broke after I migrated to@module-federation/enhanced.
I found that the mf-entry.js of MfBase dose not have the webpack runtime which define the O method.
I can't figure it out, can you help me out.
Thanks a lot!

Reproduction

...

Used Package Manager

yarn

System Info

System:
    OS: macOS 10.15.7
    CPU: (20) x64 Genuine Intel(R) CPU 0000 @ 2.50GHz
    Memory: 2.83 GB / 64.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 15.6.1

Validations

@ScriptedAlchemy
Copy link
Member

Do you have any custom split chunks set?

@lecion
Copy link
Author

lecion commented Jul 10, 2024

This is my optimization config:

    optimization: {
        splitChunks: {
            chunks: 'all',
            minSize: 20000, // 20kb
            maxInitialRequests: 12,
            cacheGroups: {
                echarts: {
                    name: 'chunk-echarts',
                    chunks: 'async',
                    priority: 20,
                    test: /[\\/]node_modules[\\/]_?echarts|zrender(.*)/
                },
                abcUI: {
                    name: 'chunk-abcui',
                    chunks: 'all',
                    test: /[\\/]node_modules[\\/](@abc\/ui-pc)[\\/]/,
                    priority: 20,
                    reuseExistingChunk: true
                },
                lib: {
                    test(module) {
                        return (
                            module.size() > 160000 &&
                            /node_modules[/\\]/.test(module.nameForCondition() || '')
                        )
                    },
                    name(module) {
                        const packageNameArr = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/);
                        const packageName = packageNameArr ? packageNameArr[1] : '';
                        return `chunk-lib.${packageName.replace("@", "")}`;
                    },
                    priority: 15,
                    minChunks: 2,
                    reuseExistingChunk: true,
                },
                vendors: {
                    name: 'chunk-vendors',
                    test: /[\\/]node_modules[\\/]/,
                    priority: 10,
                    chunks: 'initial'
                },
                api: {
                    name: 'chunk-api',
                    test: /[\\/]src\/api[\\/]/,
                    minChunks: 3,
                    priority: 5,
                    reuseExistingChunk: true
                },
                commons: {
                    name: 'chunk-commons',
                    minChunks: 5, // minimum common number
                    priority: 0,
                    maxSize: 4000000,
                    reuseExistingChunk: true,
                },
            },
        },
        runtimeChunk: { name: 'runtime' },
    }

@2heal1
Copy link
Member

2heal1 commented Jul 11, 2024

try to delete optimization. runtimeChunk

@ScriptedAlchemy
Copy link
Member

yeah its most likely runtime chunk settings.

@lecion
Copy link
Author

lecion commented Jul 15, 2024

@2heal1 @ScriptedAlchemy
Thank you for your help. I deleted the optimization.runtimeChunk option, and it works.
But it loses the optimization benefits. Is there a way to keep Module Federation and runtime chunk together?

@ScriptedAlchemy
Copy link
Member

on federation plugin, set runtime: false - this will force a full runtime for container files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants