Skip to content

Commit ae9cb73

Browse files
committed
Remove unnecessary regex
1 parent a7896b5 commit ae9cb73

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

packages/nextjs/src/config/loaders/dataFetchersLoader.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ export default function wrapDataFetchersLoader(this: LoaderThis<LoaderOptions>,
112112
}
113113

114114
// We know one or the other will be defined, depending on the version of webpack being used
115-
const { projectDir, pagesDir, underscoreAppRegex, underscoreDocumentRegex, underscoreErrorRegex } =
116-
'getOptions' in this ? this.getOptions() : this.query;
115+
const { projectDir, pagesDir } = 'getOptions' in this ? this.getOptions() : this.query;
117116

118117
// Get the parameterized route name from this page's filepath
119118
const parameterizedRouteName = path
@@ -157,13 +156,13 @@ export default function wrapDataFetchersLoader(this: LoaderThis<LoaderOptions>,
157156
import { default as _sentry_default } from "${this.resourcePath}?sentry-proxy-loader";
158157
import { withSentryGetInitialProps } from "@sentry/nextjs";`;
159158

160-
if (this.resourcePath.match(underscoreAppRegex)) {
159+
if (parameterizedRouteName === '/_app') {
161160
// getInitialProps signature is a bit different in _app.js so we need a different wrapper
162161
// Currently a no-op
163-
} else if (this.resourcePath.match(underscoreErrorRegex)) {
162+
} else if (parameterizedRouteName === '/_error') {
164163
// getInitialProps behaviour is a bit different in _error.js so we probably want different wrapper
165164
// Currently a no-op
166-
} else if (this.resourcePath.match(underscoreDocumentRegex)) {
165+
} else if (parameterizedRouteName === '/_document') {
167166
// getInitialProps signature is a bit different in _document.js so we need a different wrapper
168167
// Currently a no-op
169168
} else {

packages/nextjs/src/config/webpack.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@ export function constructWebpackConfigFunction(
7878
],
7979
};
8080

81-
const underscoreAppRegex = new RegExp(`${escapeStringForRegex(projectDir)}(/src)?/pages/_app\\.(jsx?|tsx?)`);
82-
const underscoreErrorRegex = new RegExp(`${escapeStringForRegex(projectDir)}(/src)?/pages/_error\\.(jsx?|tsx?)`);
83-
const underscoreDocumentRegex = new RegExp(
84-
`${escapeStringForRegex(projectDir)}(/src)?/pages/_document\\.(jsx?|tsx?)`,
85-
);
86-
8781
if (userSentryOptions.experiments?.autoWrapDataFetchers) {
8882
const pagesDir = newConfig.resolve?.alias?.['private-next-pages'] as string;
8983

@@ -93,13 +87,7 @@ export function constructWebpackConfigFunction(
9387
use: [
9488
{
9589
loader: path.resolve(__dirname, 'loaders/dataFetchersLoader.js'),
96-
options: {
97-
projectDir,
98-
pagesDir,
99-
underscoreAppRegex,
100-
underscoreErrorRegex,
101-
underscoreDocumentRegex,
102-
},
90+
options: { projectDir, pagesDir },
10391
},
10492
],
10593
});

0 commit comments

Comments
 (0)