Skip to content

Commit

Permalink
Move instrumentation into src directory. Add webpack config in Next c…
Browse files Browse the repository at this point in the history
…onfig to ignore the dependency warning
  • Loading branch information
stefl committed Aug 29, 2024
1 parent 377045c commit 51fe224
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
5 changes: 0 additions & 5 deletions apps/nextjs/instrumentation.ts

This file was deleted.

17 changes: 16 additions & 1 deletion apps/nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const getConfig = async (phase) => {
BRANCH: process.env.BRANCH,
DEPLOY_CONTEXT: process.env.CONTEXT,
},
webpack: (config, { dev }) => {
webpack: (config, { dev, isServer }) => {
if (!dev && isProductionBuild && isNextjsProductionBuildPhase) {
config.devtool = "source-map";
config.plugins.push(
Expand All @@ -114,6 +114,21 @@ const getConfig = async (phase) => {
);
}

// dd-trace outputs the following warning in the browser console:
// Critical dependency: the request of a dependency is an expression
// This is due to the use of `require` in the dd-trace codebase.
// This can be safely ignored.
// Start of dd-trace fix
if (!isServer) {
config.resolve.fallback = {
...config.resolve.fallback,
"dd-trace": false,
};
}
config.module = config.module || {};
config.module.exprContextCritical = false;
// End of dd-trace fix

return config;
},
};
Expand Down
12 changes: 8 additions & 4 deletions apps/nextjs/src/instrumentation.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('../sentry.server.config');
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("../sentry.server.config");
}

if (process.env.NEXT_RUNTIME === 'edge') {
await import('../sentry.edge.config');
if (process.env.NEXT_RUNTIME === "edge") {
await import("../sentry.edge.config");
}

if (process.env.NEXT_RUNTIME === "nodejs") {
await import("./instrumentation/tracer");
}
}
File renamed without changes.

0 comments on commit 51fe224

Please sign in to comment.