-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(nuxt): Inject sentry config with Nuxt addPluginTemplate
#12760
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
Conversation
addPluginTemplate
size-limit report 📦
|
packages/nuxt/package.json
Outdated
@@ -42,7 +42,7 @@ | |||
"nuxt": "3.x" | |||
}, | |||
"dependencies": { | |||
"@nuxt/kit": "^3.12.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you know, is it normal for plugins like sentry to directly depend on nuxt kit or is it more like a peer dep thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it as a dependency in other Nuxt modules and therefore added it there too
packages/nuxt/src/common/utils.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: I find it odd to place this file into a common
folder. The common folder usually denotes things that may run in any runtime. The code in this file is only allowed to run during the build right? Same goes for the other build code.
packages/nuxt/src/module.ts
Outdated
const serverConfigFile = findDefaultSdkInitFile('server'); | ||
|
||
if (serverConfigFile) { | ||
nuxt.options.alias['#sentry-server-config'] = buildDirResolver.resolve(`/${serverConfigFile}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Maybe there's a way to get rid of this alias indirection by rendering buildDirResolver.resolve(/${clientConfigFile})
directly into the template.
packages/nuxt/src/module.ts
Outdated
if (clientConfigFile) { | ||
nuxt.options.alias['#sentry-client-config'] = buildDirResolver.resolve(`/${clientConfigFile}`); | ||
|
||
injectSentryConfigImport('#sentry-client-config'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: I have a feeling we're including both templates for client and server in both bundles, since we are not setting the mode
option.
packages/nuxt/README.md
Outdated
if (import.meta.env.SSR) { | ||
Sentry.init({ | ||
dsn: env.DSN, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: I think if we set a mode in addPluginTemplate
we can get rid of the if statements around sentry.init.
Adding the import snippet with
addPluginTemplate
(docs) instead of modifying the root component code.closes #12759