Skip to content

Commit 538e087

Browse files
committed
Get the path from sentry-cli
1 parent 21c64ac commit 538e087

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

packages/nextjs/src/config/webpack.ts

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/* eslint-disable max-lines */
2+
// eslint-disable-next-line import/no-extraneous-dependencies
3+
import * as SentryCLI from '@sentry/cli';
24
import { getSentryRelease } from '@sentry/node';
35
import { arrayify, dropUndefinedKeys, escapeStringForRegex, logger } from '@sentry/utils';
46
import { default as SentryWebpackPlugin } from '@sentry/webpack-plugin';
@@ -456,22 +458,6 @@ export function getWebpackPluginOptions(
456458
return { ...defaultPluginOptions, ...userPluginOptions };
457459
}
458460

459-
/**
460-
* NOTE: We're faking `require.resolve` here as a workaround for @vercel/nft detecting the binary itself as a hard
461-
* dependency and always including it in the bundle, which is not what we want.
462-
*
463-
* ref: https://github.com/getsentry/sentry-javascript/issues/3865
464-
* ref: https://github.com/vercel/nft/issues/203
465-
*/
466-
function ensureCLIBinaryExists(): boolean {
467-
for (const node_modulesPath of module.paths) {
468-
if (fs.existsSync(path.resolve(node_modulesPath, '@sentry/cli/sentry-cli'))) {
469-
return true;
470-
}
471-
}
472-
return false;
473-
}
474-
475461
/** Check various conditions to decide if we should run the plugin */
476462
function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions: UserSentryOptions): boolean {
477463
const { isServer, dev: isDev } = buildContext;
@@ -485,7 +471,7 @@ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions
485471
// architecture-specific version of the `sentry-cli` binary. If `yarn install`, `npm install`, or `npm ci` are run
486472
// with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users
487473
// try to build their apps.)
488-
if (!ensureCLIBinaryExists()) {
474+
if (!fs.existsSync(SentryCLI.default.getPath())) {
489475
return false;
490476
}
491477

0 commit comments

Comments
 (0)