1- import { escapeStringForRegex , logger } from '@sentry/utils' ;
1+ import { escapeStringForRegex , logger , stringMatchesSomePattern } from '@sentry/utils' ;
22import * as fs from 'fs' ;
33import * as path from 'path' ;
44
@@ -8,6 +8,7 @@ import { LoaderThis } from './types';
88type LoaderOptions = {
99 pagesDir : string ;
1010 pageExtensionRegex : string ;
11+ excludeServerRoutes : Array < RegExp | string > ;
1112} ;
1213
1314/**
@@ -17,7 +18,11 @@ type LoaderOptions = {
1718 */
1819export default async function proxyLoader ( this : LoaderThis < LoaderOptions > , userCode : string ) : Promise < string > {
1920 // We know one or the other will be defined, depending on the version of webpack being used
20- const { pagesDir, pageExtensionRegex } = 'getOptions' in this ? this . getOptions ( ) : this . query ;
21+ const {
22+ pagesDir,
23+ pageExtensionRegex,
24+ excludeServerRoutes = [ ] ,
25+ } = 'getOptions' in this ? this . getOptions ( ) : this . query ;
2126
2227 // Get the parameterized route name from this page's filepath
2328 const parameterizedRoute = path
@@ -34,6 +39,11 @@ export default async function proxyLoader(this: LoaderThis<LoaderOptions>, userC
3439 // homepage), sub back in the root route
3540 . replace ( / ^ $ / , '/' ) ;
3641
42+ // Skip explicitly-ignored pages
43+ if ( stringMatchesSomePattern ( parameterizedRoute , excludeServerRoutes , true ) ) {
44+ return userCode ;
45+ }
46+
3747 // We don't want to wrap twice (or infinitely), so in the proxy we add this query string onto references to the
3848 // wrapped file, so that we know that it's already been processed. (Adding this query string is also necessary to
3949 // convince webpack that it's a different file than the one it's in the middle of loading now, so that the originals
0 commit comments