Skip to content

Commit d2299a2

Browse files
authored
fix(nuxt): Remove setting @sentry/nuxt external (#16444)
This reverts commit 6e61f82. Reverts this PR: #16407 `@sentry/nuxt` is not added as dependency in the `node_modules` of the build output after version 3.15.0 as mentioned here: #16422 fixes #16422
1 parent feb2ef3 commit d2299a2

File tree

3 files changed

+0
-96
lines changed

3 files changed

+0
-96
lines changed

packages/nuxt/src/vite/addServerConfig.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { SentryNuxtModuleOptions } from '../common/types';
88
import {
99
constructFunctionReExport,
1010
constructWrappedFunctionExportQuery,
11-
getExternalOptionsWithSentryNuxt,
1211
getFilenameFromNodeStartCommand,
1312
QUERY_END_INDICATOR,
1413
removeSentryQueryFromPath,
@@ -131,13 +130,6 @@ function injectServerConfigPlugin(nitro: Nitro, serverConfigFile: string, debug?
131130
return {
132131
name: 'rollup-plugin-inject-sentry-server-config',
133132

134-
options(opts) {
135-
return {
136-
...opts,
137-
external: getExternalOptionsWithSentryNuxt(opts.external),
138-
};
139-
},
140-
141133
buildStart() {
142134
const configPath = createResolver(nitro.options.srcDir).resolve(`/${serverConfigFile}`);
143135

packages/nuxt/src/vite/utils.ts

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { consoleSandbox } from '@sentry/core';
22
import * as fs from 'fs';
33
import type { Nuxt } from 'nuxt/schema';
44
import * as path from 'path';
5-
import type { ExternalOption } from 'rollup';
65

76
/**
87
* Find the default SDK init file for the given type (client or server).
@@ -73,35 +72,6 @@ export function removeSentryQueryFromPath(url: string): string {
7372
return url.replace(regex, '');
7473
}
7574

76-
/**
77-
* Add @sentry/nuxt to the external options of the Rollup configuration to prevent Rollup bundling all dependencies
78-
* that would result in adding imports from OpenTelemetry libraries etc. to the server build.
79-
*/
80-
export function getExternalOptionsWithSentryNuxt(previousExternal: ExternalOption | undefined): ExternalOption {
81-
const sentryNuxt = /^@sentry\/nuxt$/;
82-
let external: ExternalOption;
83-
84-
if (typeof previousExternal === 'function') {
85-
external = new Proxy(previousExternal, {
86-
apply(target, thisArg, args: [string, string | undefined, boolean]) {
87-
const [source] = args;
88-
if (sentryNuxt.test(source)) {
89-
return true;
90-
}
91-
return Reflect.apply(target, thisArg, args);
92-
},
93-
});
94-
} else if (Array.isArray(previousExternal)) {
95-
external = [sentryNuxt, ...previousExternal];
96-
} else if (previousExternal) {
97-
external = [sentryNuxt, previousExternal];
98-
} else {
99-
external = sentryNuxt;
100-
}
101-
102-
return external;
103-
}
104-
10575
/**
10676
* Extracts and sanitizes function re-export and function wrap query parameters from a query string.
10777
* If it is a default export, it is not considered for re-exporting.

packages/nuxt/test/vite/utils.test.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
constructWrappedFunctionExportQuery,
77
extractFunctionReexportQueryParameters,
88
findDefaultSdkInitFile,
9-
getExternalOptionsWithSentryNuxt,
109
getFilenameFromNodeStartCommand,
1110
QUERY_END_INDICATOR,
1211
removeSentryQueryFromPath,
@@ -367,60 +366,3 @@ export { foo_sentryWrapped as foo };
367366
expect(result).toBe('');
368367
});
369368
});
370-
371-
describe('getExternalOptionsWithSentryNuxt', () => {
372-
it('should return sentryExternals when previousExternal is undefined', () => {
373-
const result = getExternalOptionsWithSentryNuxt(undefined);
374-
expect(result).toEqual(/^@sentry\/nuxt$/);
375-
});
376-
377-
it('should merge sentryExternals with array previousExternal', () => {
378-
const previousExternal = [/vue/, 'react'];
379-
const result = getExternalOptionsWithSentryNuxt(previousExternal);
380-
expect(result).toEqual([/^@sentry\/nuxt$/, /vue/, 'react']);
381-
});
382-
383-
it('should create array with sentryExternals and non-array previousExternal', () => {
384-
const previousExternal = 'vue';
385-
const result = getExternalOptionsWithSentryNuxt(previousExternal);
386-
expect(result).toEqual([/^@sentry\/nuxt$/, 'vue']);
387-
});
388-
389-
it('should create a proxy when previousExternal is a function', () => {
390-
const mockExternalFn = vi.fn().mockReturnValue(false);
391-
const result = getExternalOptionsWithSentryNuxt(mockExternalFn);
392-
393-
expect(typeof result).toBe('function');
394-
expect(result).toBeInstanceOf(Function);
395-
});
396-
397-
it('should return true from proxied function when source is @sentry/nuxt', () => {
398-
const mockExternalFn = vi.fn().mockReturnValue(false);
399-
const result = getExternalOptionsWithSentryNuxt(mockExternalFn);
400-
401-
// @ts-expect-error - result is a function
402-
const output = result('@sentry/nuxt', undefined, false);
403-
expect(output).toBe(true);
404-
expect(mockExternalFn).not.toHaveBeenCalled();
405-
});
406-
407-
it('should return false from proxied function and call function when source just includes @sentry/nuxt', () => {
408-
const mockExternalFn = vi.fn().mockReturnValue(false);
409-
const result = getExternalOptionsWithSentryNuxt(mockExternalFn);
410-
411-
// @ts-expect-error - result is a function
412-
const output = result('@sentry/nuxt/dist/index.js', undefined, false);
413-
expect(output).toBe(false);
414-
expect(mockExternalFn).toHaveBeenCalledWith('@sentry/nuxt/dist/index.js', undefined, false);
415-
});
416-
417-
it('should call original function when source does not include @sentry/nuxt', () => {
418-
const mockExternalFn = vi.fn().mockReturnValue(false);
419-
const result = getExternalOptionsWithSentryNuxt(mockExternalFn);
420-
421-
// @ts-expect-error - result is a function
422-
const output = result('vue', undefined, false);
423-
expect(output).toBe(false);
424-
expect(mockExternalFn).toHaveBeenCalledWith('vue', undefined, false);
425-
});
426-
});

0 commit comments

Comments
 (0)