Skip to content

Commit 2f78802

Browse files
committed
remove redundant pagesDirectory variable
1 parent fe1a22c commit 2f78802

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,12 @@ export function constructWebpackConfigFunction(
8282
if (userSentryOptions.autoInstrumentServerFunctions !== false) {
8383
const pagesDir = newConfig.resolve?.alias?.['private-next-pages'] as string;
8484

85-
// Next.js allows users to have the `pages` folder inside a `src` folder, however "`src/pages` will be ignored
86-
// if `pages` is present in the root directory"
87-
// - https://nextjs.org/docs/advanced-features/src-directory
88-
const shouldIncludeSrcDirectory = !fs.existsSync(path.resolve(projectDir, 'pages'));
89-
const pagesDirectory = shouldIncludeSrcDirectory // We're intentionally not including slashes in the paths because we wanne let node do the path resolution for Windows
90-
? path.resolve(projectDir, 'src', 'pages')
91-
: path.resolve(projectDir, 'pages');
92-
9385
// Default page extensions per https://github.com/vercel/next.js/blob/f1dbc9260d48c7995f6c52f8fbcc65f08e627992/packages/next/server/config-shared.ts#L161
9486
const pageExtensions = userNextConfig.pageExtensions || ['tsx', 'ts', 'jsx', 'js'];
9587
const pageExtensionRegex = pageExtensions.map(escapeStringForRegex).join('|');
9688

9789
newConfig.module.rules.push({
98-
// Nextjs allows the `pages` folder to optionally live inside a `src` folder
99-
test: new RegExp(`^${escapeStringForRegex(pagesDirectory)}.*\\.(${pageExtensionRegex})$`),
90+
test: new RegExp(`^${escapeStringForRegex(pagesDir)}.*\\.(${pageExtensionRegex})$`),
10091
use: [
10192
{
10293
loader: path.resolve(__dirname, 'loaders/proxyLoader.js'),

packages/nextjs/test/config/fixtures.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const serverWebpackConfig: WebpackConfigObject = {
5656
output: { filename: '[name].js', path: '/Users/Maisey/projects/squirrelChasingSimulator/.next' },
5757
target: 'node',
5858
context: '/Users/Maisey/projects/squirrelChasingSimulator',
59+
resolve: { alias: { 'private-next-pages': '/Users/Maisey/projects/squirrelChasingSimulator/pages' } },
5960
};
6061
export const clientWebpackConfig: WebpackConfigObject = {
6162
entry: () =>

0 commit comments

Comments
 (0)