From b62c5d6d71eca9788489f15770bc46b094ece64b Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Wed, 11 Dec 2024 14:40:58 +0100 Subject: [PATCH] add snippet --- .../common/troubleshooting/index.mdx | 48 ++++++++++++++----- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/docs/platforms/javascript/common/troubleshooting/index.mdx b/docs/platforms/javascript/common/troubleshooting/index.mdx index 228c8420cdec4..fef140d8392ad 100644 --- a/docs/platforms/javascript/common/troubleshooting/index.mdx +++ b/docs/platforms/javascript/common/troubleshooting/index.mdx @@ -437,22 +437,22 @@ Learn more about fixing these caching issues in the - When using pnpm, you might encounter errors related to packages that can't be external, particularly with packages like `import-in-the-middle` and `require-in-the-middle`. These errors typically occur due to pnpm's strict dependency management and hoisting behavior. +When using pnpm, you might encounter errors related to packages that can't be external, particularly with packages like `import-in-the-middle` and `require-in-the-middle`. These errors typically occur due to pnpm's strict dependency management and hoisting behavior. - While adding these packages as direct dependencies might remove the warning messages, it often doesn't resolve the underlying functionality issues: +While adding these packages as direct dependencies might remove the warning messages, it often doesn't resolve the underlying functionality issues: - ```bash - pnpm add import-in-the-middle require-in-the-middle - ``` +```bash +pnpm add import-in-the-middle require-in-the-middle +``` - As a workaround, create or modify `.npmrc` in your project root: +As a workaround, create or modify `.npmrc` in your project root: - ```npmrc - shamefully-hoist=true - ``` - +```npmrc +shamefully-hoist=true +``` + **Note**: While `shamefully-hoist=true` usually isn't the ideal solution from a dependency management perspective, it's sometimes necessary for compatibility with certain packages that expect Node.js module resolution behavior similar to npm or yarn. - + @@ -542,7 +542,31 @@ Learn more about fixing these caching issues in the - If you want to set up Sentry's Next.js SDK in an Nx monorepo context, please refer to [this guide](https://nx.dev/recipes/next/next-config-setup#manually-composing-plugins-nx-15-and-prior). + To set up Sentry's Next.js SDK in an Nx monorepo context, consider the following setup: + + ```js {filename:next.config.js} + const nextConfig = { + // ... + }; + + const plugins = [ + // Your plugins excluding withNx + ]; + + module.exports = async (phase, context) => { + let updatedConfig = plugins.reduce((acc, fn) => fn(acc), nextConfig); + + // Apply the async function that `withNx` returns. + updatedConfig = await withNx(updatedConfig)(phase, context); + + return updatedConfig; + }; + + // The Sentry plugin should always be applied last + const { withSentryConfig } = require('@sentry/nextjs'); + module.exports = withSentryConfig(module.exports) + ``` +