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

isomorphicRslog.createLogger is not a function #3137

Open
5 tasks done
es-hungnguyen opened this issue Oct 30, 2024 · 6 comments
Open
5 tasks done

isomorphicRslog.createLogger is not a function #3137

es-hungnguyen opened this issue Oct 30, 2024 · 6 comments

Comments

@es-hungnguyen
Copy link

es-hungnguyen commented Oct 30, 2024

Describe the bug

I create a new project and add @module-federation/enhanced v0.6.14, then import '@module-federation/enhanced/runtime'; and got the error
isomorphicRslog.createLogger is not a function TypeError: isomorphicRslog.createLogger is not a function

Reproduction

install v0.6.14

Used Package Manager

yarn

System Info

MacOS 15.0.1
Chrome

Validations

@ScriptedAlchemy
Copy link
Member

please provide a repo

@mes113
Copy link

mes113 commented Nov 5, 2024

i am currently having a similar issue

index.cjs.js:102 Uncaught TypeError: isomorphicRslog.createLogger is not a function
    at createLogger (index.cjs.js:102:44)
    at ../../node_modules/.pnpm/@[email protected]/node_modules/@module-federation/sdk/dist/index.cjs.js (index.cjs.js:116:16)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:22:1)
    at fn (hot module replacement:61:1)
    at ../../node_modules/.pnpm/@[email protected]/node_modules/@module-federation/runtime/dist/index.cjs.js (index.cjs.js:4:11)
    at options.factory (react refresh:6:1)
    at __webpack_require__ (bootstrap:22:1)
    at fn (hot module replacement:61:1)
    at ../../node_modules/.pnpm/@[email protected]/node_modules/@module-federation/webpack-bundler-runtime/dist/index.cjs.js (index.cjs.js:3:15)

@mes113
Copy link

mes113 commented Nov 5, 2024

When we update our project that uses @module-federation/enhanced to version 0.6.3 to 0.6.16 we are having the issue with
isomorphicRslog.createLogger.

craco config:

webpack: {
      alias: {
        "@": path.resolve(__dirname, "src"),
      },
      configure: {
        optimization: {
          runtimeChunk: false,
          splitChunks: false,
        },
        output: {
          publicPath: "auto",
        },
        experiments: {
          topLevelAwait: true,
        },
        devtool: "inline-source-map",
      },
      plugins: {
        add: [
          new RetryChunkLoadPlugin({
            cacheBust: function() {
                          return Date.now();
                      },
            retryDelay: 3000,
            maxRetries: 5,
          }),
          new ModuleFederationPlugin({
            name: "ParkingAttendantMFA",
            filename: "remoteEntry.js",
            manifest: true,
            exposes: {
              "./Attendants":
                "./src/components/Attendants/AttendantsPage",
            },
            shared: [
             ....
            ],
            remotes: {
              Common: Common@url/mf-manifest.json,
              Dashboard: Dashboard@$url2/mf-manifest.json,
            },
          }),
        ],
      },

one more thing ... looks like a problem related to PNPM. with NPM it is working correctly.

I have 2 different micro-frontends. One with PNPM another one with NPM
last version where everything works with PNPM "@module-federation/enhanced": "0.6.13"

@ScriptedAlchemy @2heal1

@ScriptedAlchemy
Copy link
Member

@mes113 you must provide a repository

@mes113
Copy link

mes113 commented Nov 5, 2024

@ScriptedAlchemy https://github.com/mes113/mf-issue-example
repository with example

@ScriptedAlchemy
Copy link
Member

ScriptedAlchemy commented Nov 5, 2024

your build is treating .cjs as file-loader

image

Add correct resolve extensions for cjs files, the build configuration seems to be non-compliant with modern specifications.

https://webpack.js.org/configuration/resolve/#resolveextensionalias

You may also have to fix the loader configuration or CRA since babel loader regex may only cover .js and not .mjs,.cjs,.js

I would recomend using rsbuild since CRA is long since dead. https://rspack.dev/guide/migration/cra

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