-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nuxt): Add @sentry/nuxt
as external in Rollup
#16407
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
packages/nuxt/src/vite/utils.ts
Outdated
apply(target, thisArg, args: [string, string | undefined, boolean]) { | ||
const [source] = args; | ||
if ( | ||
sentryExternals.some(external => (typeof external === 'string' ? source === external : external.test(source))) |
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: Are we ever expecting more than one external here? The comment and function name make it sound like it's always only going to be @sentry/nuxt
and nothing else. I feel like we can just simplify this code to /^@sentry\/nuxt$/.test(source)
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.
true, I had 'import-in-the-middle' added to the array at first as well. But as this is actually not necessary, I can remove it 👍
packages/nuxt/src/vite/utils.ts
Outdated
* that would result in adding imports from OpenTelemetry libraries etc. to the server build. | ||
*/ | ||
export function getExternalOptionsWithSentryNuxt(previousExternal: ExternalOption | undefined): ExternalOption { | ||
const sentryExternals = [/^@sentry\/nuxt$/]; |
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: Technically, I don't think this needs to be an array at all, right? Just thinking that the .some
call below as well as the object spreads are kinda unnecessary if we only have one element in the array (in the sense of a slight perf overhead as well as code readability).
(I read Andrei's comment, so feel free to ignore this if I happen to review in an in-between state 😅)
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.
@Lms24 simplified.
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.
thx for making the changes!
The Sentry Nuxt SDK emits the Sentry config file during the Rollup build. Users add this file to their application which includes an import from
@sentry/nuxt
and the init function. This file is then added as an.mjs
file in the build output.However, when building the application, this
.mjs
file included a bunch of OpenTelemetry imports and not only the init code as every dependency from@sentry/nuxt
was traced back and bundled into the build output.By adding
@sentry/nuxt
as external, the.mjs
file really only contains the content like in the.ts
file.Could fix #15204