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

Nuxt module does not take into account "srcDir" for client instrumentation #13330

Open
3 tasks done
max-arias opened this issue Aug 12, 2024 · 4 comments
Open
3 tasks done
Assignees
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK

Comments

@max-arias
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nuxt

SDK Version

8.25.0

Framework Version

8.25.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

No response

Steps to Reproduce

The Sentry module does not seem to take into account the srcDir config, it only uses the buildDir: https://github.com/getsentry/sentry-javascript/blob/master/packages/nuxt/src/module.ts#L30

The current work around is to create a client file both under your srcDir (ie. /src) and in your buildDir (ie /)

With the upcoming Nuxt 4 change where the src files will live in another dir, we should fix this

Expected Result

We should read sentry.client.config from the srcDir without needing a copy in the buildDir

Actual Result

rollup throws an error if there's nothing in "srcDir"

@github-actions github-actions bot added the Package: nuxt Issues related to the Sentry Nuxt SDK label Aug 12, 2024
@s1gr1d
Copy link
Member

s1gr1d commented Aug 13, 2024

Thanks for already testing the experimental Nuxt SDK and filing this! We will fix this, as we want to be compatible with Nuxt 4!

@s1gr1d s1gr1d self-assigned this Aug 13, 2024
@s1gr1d
Copy link
Member

s1gr1d commented Aug 13, 2024

A follow-up question @max-arias: Why would you want to add the config file in the src directory? Are there any issues with creating the Sentry config along with the Nuxt config in the root directory?

@max-arias
Copy link
Author

max-arias commented Aug 13, 2024

@s1gr1d Yeah, if I try placing just sentry.client.config.ts at the root of my project, outside src I get a build error. This is after removing .nuxt/ and running a yarn install again.

ℹ Building client...                                                                                                                                                     10:38:17 AM
ℹ vite v5.4.0 building for production...                                                                                                                                 10:38:17 AM
[sentry-vite-plugin] Info: Sending telemetry data on issues and performance to Sentry. To disable telemetry, set `options.telemetry` to `false`.
ℹ ✓ 52 modules transformed.                                                                                                                                              10:38:18 AM

 ERROR  x Build failed in 1.15s                                                                                                                                           10:38:18 AM


[10:38:18 AM]  ERROR  Nuxt Build Error: [vite]: Rollup failed to resolve import "/sentry.client.config.ts" from "virtual:nuxt:/Users/<redacted>/dev/<redacted>/.nuxt/sentry-client-config.mjs".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to
  build.rollupOptions.external
  at viteWarn (node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:65463:17)
  at onRollupWarning (node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:65495:5)
  at onwarn (node_modules/vite/dist/node/chunks/dep-NjL7WTE1.js:65158:7)
  at node_modules/rollup/dist/es/shared/node-entry.js:18625:13
  at Object.logger [as onLog] (node_modules/rollup/dist/es/shared/node-entry.js:20280:9)
  at ModuleLoader.handleInvalidResolvedId (node_modules/rollup/dist/es/shared/node-entry.js:19215:26)
  at node_modules/rollup/dist/es/shared/node-entry.js:19173:26
  • If I place it just in src the the client is not initialized (it doesnt read the file)
  • If I place in both I get no errors and the client is initialized, but it's a bit redundant 😅

@s1gr1d
Copy link
Member

s1gr1d commented Aug 13, 2024

Thanks for clarifying, I'll take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nuxt Issues related to the Sentry Nuxt SDK
Projects
Status: No status
Development

No branches or pull requests

2 participants