Skip to content

Commit c245c7e

Browse files
lobsterkatieonurtemizkan
authored andcommitted
ref(nextjs): Remove resolve.alias treeshaking hack (#4276)
In #3978, code was introduced to prevent node tracing integrations (mongo, postgres, etc) from appearing in the browser bundle where they don't belong. However, as part of our larger push to make our code more treeshakable, we recently changed how we export those integrations[1], making the previous workaround unnecessary. As a bonus, this should fix a rendering issue some users were having when using the `fallback` flag. Tested locally and on vercel. Fixes #4090. [1] #4204
1 parent c258816 commit c245c7e

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

packages/nextjs/src/config/webpack.ts

-18
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ export function constructWebpackConfigFunction(
6161
const origEntryProperty = newConfig.entry;
6262
newConfig.entry = async () => addSentryToEntryProperty(origEntryProperty, buildContext);
6363

64-
// In webpack 5, you can get webpack to replace any module you'd like with an empty object, just by setting its
65-
// `resolve.alias` value to `false`. Not much of our code is neatly separated into "things node needs" and "things
66-
// the browser needs," but where it is, we can save ~1.6 kb in eventual bundle size by excluding code we know we
67-
// don't need. (Normally this would only matter for the client side, but because vercel turns backend code into
68-
// serverless functions, it's worthwhile to do it for both.)
69-
if (buildContext.webpack.version.startsWith('5')) {
70-
const excludedTracingDir = buildContext.isServer ? 'browser' : 'integrations/node';
71-
newConfig.resolve = {
72-
...newConfig.resolve,
73-
alias: {
74-
...newConfig.resolve?.alias,
75-
[path.resolve(buildContext.dir, `./node_modules/@sentry/tracing/esm/${excludedTracingDir}`)]: false,
76-
// TODO It's not clear if it will ever pull from `dist` (in testing it never does), so we may not need this.
77-
[path.resolve(buildContext.dir, `./node_modules/@sentry/tracing/dist/${excludedTracingDir}`)]: false,
78-
},
79-
};
80-
}
81-
8264
// Enable the Sentry plugin (which uploads source maps to Sentry when not in dev) by default
8365
const enableWebpackPlugin = buildContext.isServer
8466
? !userNextConfig.sentry?.disableServerWebpackPlugin

0 commit comments

Comments
 (0)