sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

[Nuxt] Improvements and Stabilization

Open s1gr1d opened this issue 7 months ago • 0 comments

Description

In most cases, the way a Nuxt application and the Sentry configuration is built does not create problems. However, there are some edge cases that pop up from time to time and also seem very hard to reproduce.

Issue List

  • https://github.com/getsentry/sentry-javascript/issues/15204

Those are some insights I gained so far while digging into build-folder related topics:

1. @sentry/nuxt is not included in the build output node_modules

Ideally, the sentry.server.config.mjs file in the build output should look like this (before Nuxt v3.15.0 with npm):

import process from 'node:process';
// debug ID code
import * as Sentry from '@sentry/nuxt';
import './chunks/virtual/_sentry-release-injection-file.mjs';

Sentry.init({
  dsn: "https://dsn.url",
  tracesSampleRate: 1,
});
//# sourceMappingURL=sentry.server.config.mjs.map

However, after Nuxt version 3.15.0, @sentry/nuxt is not is not included in the build output folder. The dependency is inlined with imports from @sentry/node and @sentry/core. This is fine, but kept in mind when putting libraries into Rollup externals.

After nightly 3.15.0-28892109.0e84cb9a (which corresponds to this commit) the dependency @sentry/nuxt is not added anymore.

It could be another commit as well - between those two nightlies are several commits:

  '3.15.0-28890210.3b129290' --> adds dependency
  '3.15.0-28892109.0e84cb9a' --> does not add it

2. sentry.server.config.mjs includes imports that should not be there

When using yarn, there is an import from './chunks/nitro/nitro.mjs'; inside sentry.server.config.mjs which breaks the early-import of the SDK.

2.1. sentry.server.config.mjs bundles in OTel imports

This already happened but I am not able to reproduce this myself anymore. At some point, the sentry.server.config.mjs file in the build output bundles in all of @opentelemetry/... imports and the file gets super long.

s1gr1d avatar Jun 02 '25 14:06 s1gr1d