Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(nextjs): Remove resolve.alias treeshaking hack #4276

Merged
merged 1 commit into from Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 0 additions & 18 deletions packages/nextjs/src/config/webpack.ts
Expand Up @@ -61,24 +61,6 @@ export function constructWebpackConfigFunction(
const origEntryProperty = newConfig.entry;
newConfig.entry = async () => addSentryToEntryProperty(origEntryProperty, buildContext);

// In webpack 5, you can get webpack to replace any module you'd like with an empty object, just by setting its
// `resolve.alias` value to `false`. Not much of our code is neatly separated into "things node needs" and "things
// the browser needs," but where it is, we can save ~1.6 kb in eventual bundle size by excluding code we know we
// don't need. (Normally this would only matter for the client side, but because vercel turns backend code into
// serverless functions, it's worthwhile to do it for both.)
if (buildContext.webpack.version.startsWith('5')) {
const excludedTracingDir = buildContext.isServer ? 'browser' : 'integrations/node';
newConfig.resolve = {
...newConfig.resolve,
alias: {
...newConfig.resolve?.alias,
[path.resolve(buildContext.dir, `./node_modules/@sentry/tracing/esm/${excludedTracingDir}`)]: false,
// TODO It's not clear if it will ever pull from `dist` (in testing it never does), so we may not need this.
[path.resolve(buildContext.dir, `./node_modules/@sentry/tracing/dist/${excludedTracingDir}`)]: false,
},
};
}

// Enable the Sentry plugin (which uploads source maps to Sentry when not in dev) by default
const enableWebpackPlugin = buildContext.isServer
? !userNextConfig.sentry?.disableServerWebpackPlugin
Expand Down