Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions packages/nextjs/src/config/getBuildPluginOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,24 +124,22 @@ function createSourcemapUploadAssetPatterns(

/**
* Creates ignore patterns for source map uploads
* Note: These patterns are relative to the upload path, not absolute paths
*/
function createSourcemapUploadIgnorePattern(
normalizedDistPath: string,
widenClientFileUpload: boolean = false,
): string[] {
function createSourcemapUploadIgnorePattern(widenClientFileUpload: boolean = false): string[] {
const ignore: string[] = [];

// We only add main-* files if the user has not opted into it
if (!widenClientFileUpload) {
ignore.push(path.posix.join(normalizedDistPath, FILE_PATTERNS.MAIN_CHUNKS));
ignore.push(FILE_PATTERNS.MAIN_CHUNKS);
}

// Always ignore these patterns
ignore.push(
path.posix.join(normalizedDistPath, FILE_PATTERNS.FRAMEWORK_CHUNKS),
path.posix.join(normalizedDistPath, FILE_PATTERNS.FRAMEWORK_CHUNKS_DOT),
path.posix.join(normalizedDistPath, FILE_PATTERNS.POLYFILLS_CHUNKS),
path.posix.join(normalizedDistPath, FILE_PATTERNS.WEBPACK_CHUNKS),
FILE_PATTERNS.FRAMEWORK_CHUNKS,
FILE_PATTERNS.FRAMEWORK_CHUNKS_DOT,
FILE_PATTERNS.POLYFILLS_CHUNKS,
FILE_PATTERNS.WEBPACK_CHUNKS,
);

return ignore;
Expand Down Expand Up @@ -250,7 +248,7 @@ export function getBuildPluginOptions({
widenClientFileUpload,
);

const sourcemapUploadIgnore = createSourcemapUploadIgnorePattern(normalizedDistDirAbsPath, widenClientFileUpload);
const sourcemapUploadIgnore = createSourcemapUploadIgnorePattern(widenClientFileUpload);

const filesToDeleteAfterUpload = createFilesToDeleteAfterUploadPattern(
normalizedDistDirAbsPath,
Expand Down
85 changes: 46 additions & 39 deletions packages/nextjs/test/config/getBuildPluginOptions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ describe('getBuildPluginOptions', () => {
sourcemaps: {
assets: ['/path/to/.next/server', '/path/to/.next/static/chunks/pages', '/path/to/.next/static/chunks/app'],
ignore: [
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
],
filesToDeleteAfterUpload: undefined,
rewriteSources: expect.any(Function),
Expand Down Expand Up @@ -93,6 +93,13 @@ describe('getBuildPluginOptions', () => {
'C:/Users/test/.next/static/chunks/pages/**',
'C:/Users/test/.next/static/chunks/app/**',
]);
expect(result.sourcemaps?.ignore).toEqual([
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
});
});

Expand All @@ -116,11 +123,11 @@ describe('getBuildPluginOptions', () => {
'/path/to/.next/static/chunks/app/**',
]);
expect(result.sourcemaps?.ignore).toEqual([
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
expect(result.reactComponentAnnotation).toBeDefined();
});
Expand All @@ -138,10 +145,10 @@ describe('getBuildPluginOptions', () => {

expect(result.sourcemaps?.assets).toEqual(['/path/to/.next/static/chunks/**']);
expect(result.sourcemaps?.ignore).toEqual([
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
});

Expand All @@ -156,11 +163,11 @@ describe('getBuildPluginOptions', () => {
expect(result._metaOptions?.loggerPrefixOverride).toBe('[@sentry/nextjs - Node.js]');
expect(result.sourcemaps?.assets).toEqual(['/path/to/.next/server/**', '/path/to/.next/serverless/**']);
expect(result.sourcemaps?.ignore).toEqual([
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
expect(result.reactComponentAnnotation).toBeDefined();
});
Expand All @@ -176,11 +183,11 @@ describe('getBuildPluginOptions', () => {
expect(result._metaOptions?.loggerPrefixOverride).toBe('[@sentry/nextjs - Edge]');
expect(result.sourcemaps?.assets).toEqual(['/path/to/.next/server/**', '/path/to/.next/serverless/**']);
expect(result.sourcemaps?.ignore).toEqual([
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
expect(result.reactComponentAnnotation).toBeDefined();
});
Expand All @@ -200,11 +207,11 @@ describe('getBuildPluginOptions', () => {
'/path/to/.next/static/chunks/app',
]);
expect(result.sourcemaps?.ignore).toEqual([
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
expect(result.reactComponentAnnotation).toBeUndefined();
});
Expand All @@ -223,11 +230,11 @@ describe('getBuildPluginOptions', () => {
'/path/to/.next/static/chunks', // Turbopack uses broader pattern
]);
expect(result.sourcemaps?.ignore).toEqual([
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
]);
expect(result.reactComponentAnnotation).toBeUndefined();
});
Expand Down Expand Up @@ -755,11 +762,11 @@ describe('getBuildPluginOptions', () => {
disable: false,
assets: ['/path/to/.next/server', '/path/to/.next/static/chunks/pages', '/path/to/.next/static/chunks/app'],
ignore: [
'/path/to/.next/static/chunks/main-*',
'/path/to/.next/static/chunks/framework-*',
'/path/to/.next/static/chunks/framework.*',
'/path/to/.next/static/chunks/polyfills-*',
'/path/to/.next/static/chunks/webpack-*',
'static/chunks/main-*',
'static/chunks/framework-*',
'static/chunks/framework.*',
'static/chunks/polyfills-*',
'static/chunks/webpack-*',
],
filesToDeleteAfterUpload: undefined,
rewriteSources: expect.any(Function),
Expand Down