File tree 1 file changed +16
-0
lines changed
packages/nextjs/src/config
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,22 @@ export function constructWebpackConfigFunction(
60
60
const origEntryProperty = newConfig . entry ;
61
61
newConfig . entry = async ( ) => addSentryToEntryProperty ( origEntryProperty , buildContext ) ;
62
62
63
+ // In webpack 5, you can get webpack to replace any module you'd like with an empty object, just by setting its
64
+ // `resolve.alias` value to `false`. Not much of our code is neatly separated into "things node needs" and "things
65
+ // the browser needs," but where it is, we can save ~1.6 kb in eventual bundle size by excluding code we know we
66
+ // don't need. (Normally this would only matter for the client side, but because vercel turns backend code into
67
+ // serverless functions, it's worthwhile to do it for both.)
68
+ if ( buildContext . webpack . version . startsWith ( '5' ) ) {
69
+ const excludedTracingDir = buildContext . isServer ? 'browser' : 'integrations/node' ;
70
+ newConfig . resolve = {
71
+ ...newConfig . resolve ,
72
+ alias : {
73
+ ...newConfig . resolve ?. alias ,
74
+ [ path . resolve ( buildContext . dir , `./node_modules/@sentry/tracing/esm/${ excludedTracingDir } ` ) ] : false ,
75
+ } ,
76
+ } ;
77
+ }
78
+
63
79
// Enable the Sentry plugin (which uploads source maps to Sentry when not in dev) by default
64
80
const enableWebpackPlugin = buildContext . isServer
65
81
? ! userNextConfig . sentry ?. disableServerWebpackPlugin
You can’t perform that action at this time.
0 commit comments