Skip to content

Commit a85519a

Browse files
committed
exclude build-time files
1 parent fe1a22c commit a85519a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ export function constructWebpackConfigFunction(
105105
],
106106
});
107107
}
108+
109+
// Prevent `@vercel/nft` (which nextjs uses to determine which files are needed when packaging up a lambda) from
110+
// including any of our build-time code or dependencies. (Otherwise it'll include files like this one and even the
111+
// entirety of rollup and sucrase.)
112+
const nftPlugin = newConfig.plugins?.find((plugin: WebpackPluginInstance) => {
113+
const proto = Object.getPrototypeOf(plugin) as WebpackPluginInstance;
114+
return proto.constructor.name === 'TraceEntryPointsPlugin';
115+
}) as NFTWebpackPlugin;
116+
if (nftPlugin) {
117+
nftPlugin.excludeFiles.push(path.join(__dirname, 'index.js'));
118+
} else {
119+
__DEBUG_BUILD__ &&
120+
logger.warn(
121+
'Unable to exclude Sentry build-time helpers from nft files. Could not find `TraceEntryPointsPlugin`.',
122+
);
123+
}
108124
}
109125

110126
// The SDK uses syntax (ES6 and ES6+ features like object spread) which isn't supported by older browsers. For users

0 commit comments

Comments
 (0)