Skip to content
Closed
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
1 change: 1 addition & 0 deletions packages/nextjs/src/config/loaders/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { default as valueInjectionLoader } from './valueInjectionLoader';
export { default as prefixLoader } from './prefixLoader';
export { default as wrappingLoader } from './wrappingLoader';
export { default as sdkMultiplexerLoader } from './sdkMultiplexerLoader';
export { default as turboTestLoader } from './turboTestLoader';
14 changes: 14 additions & 0 deletions packages/nextjs/src/config/loaders/turboTestLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { LoaderThis } from './types';

/**
* Test loader for turbopack
*/
export default function (this: LoaderThis<unknown>, source: string, map: any): void {
this.async();

// @ts-expect-error this.context is not typed
// eslint-disable-next-line no-console
console.log({ t: this, resourcePath: this.resourcePath, context: this.context });

this.callback(null, source, map);
}
20 changes: 20 additions & 0 deletions packages/nextjs/src/config/turbopack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as path from 'path';

import type { NextConfigObject } from './types';

/**
* Applies the config for turbopack mode.
*/
export function applyTurbopackOptions(nextConfig: NextConfigObject): void {
nextConfig.experimental ??= {};
nextConfig.experimental.turbo ??= {};
nextConfig.experimental.turbo.rules ??= {};

const rules = nextConfig.experimental.turbo.rules;

rules['**/app/**/page.tsx'] ??= [];
rules['**/app/**/page.tsx'].unshift({
loader: path.resolve(__dirname, 'loaders', 'turboTestLoader.js'),
options: {},
});
}
6 changes: 6 additions & 0 deletions packages/nextjs/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export type NextConfigObject = {
fallback?: NextRewrite[];
}
>;
experimental?: {
turbo?: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
rules?: Record<string, { loader: string; options: any }[]>;
};
};
};

export type UserSentryOptions = {
Expand Down
3 changes: 3 additions & 0 deletions packages/nextjs/src/config/withSentryConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isThenable } from '@sentry/utils';

import { applyTurbopackOptions } from './turbopack';
import type {
ExportedNextConfig,
NextConfigFunction,
Expand Down Expand Up @@ -74,6 +75,8 @@ function getFinalConfigObject(
}
}

applyTurbopackOptions(incomingUserNextConfigObject);

return {
...incomingUserNextConfigObject,
webpack: constructWebpackConfigFunction(
Expand Down