Skip to content

feat: attempt to get this component node free#1149

Closed
kennethaasan wants to merge 1 commit intoasyncapi:masterfrom
kennethaasan:feat/node-free
Closed

feat: attempt to get this component node free#1149
kennethaasan wants to merge 1 commit intoasyncapi:masterfrom
kennethaasan:feat/node-free

Conversation

@kennethaasan
Copy link
Contributor

@kennethaasan kennethaasan commented Apr 7, 2025

Description

Please see #956 and asyncapi/parser-js#1092. I've been able to work around this issue by setting some Webpack fallbacks in the Next.js config like this:

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // The config below is needed because the AsyncAPI React component needs fs, but it doesn't really use it.
  // https://github.com/asyncapi/asyncapi-react/issues/956
  webpack: (webpackConfig) => {
    webpackConfig.resolve.fallback = { fs: false };
    return webpackConfig;
  },
};

export default nextConfig;

But this doesn't work with Next.js turbopack enabled, so I got a bit annoyed, and this is an attempt to fix that this component requires Node.js modules.

Related issue(s)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@kennethaasan
Copy link
Contributor Author

I gave up solving this, but I found a workaround for the Next.js config with turbopack enabled:

import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  // The config below is needed because the AsyncAPI React component needs fs, but it doesn't really use it.
  // https://github.com/asyncapi/asyncapi-react/issues/956
  webpack: (webpackConfig) => {
    // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
    webpackConfig.resolve.fallback = { fs: false };
    // eslint-disable-next-line @typescript-eslint/no-unsafe-return
    return webpackConfig;
  },
  experimental: {
    turbo: {
      // https://nextjs.org/docs/app/api-reference/config/next-config-js/turbo#resolving-aliases
      resolveAlias: {
        fs: {
          browser: "./mocks/empty.mjs",
        },
      },
    },
  },
};

export default nextConfig;

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

Successfully merging this pull request may close these issues.

1 participant