From 948ae24c33a516001b140863f6298aa0cab5a024 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 31 Oct 2022 15:55:42 +0100 Subject: [PATCH] Use `SentryWebpackPlugin.cliBinaryExists()` --- packages/nextjs/package.json | 2 +- packages/nextjs/src/config/webpack.ts | 24 +++------------------ yarn.lock | 31 ++++++++++++++++++++++----- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 806facb2e828..f7e11c4154b2 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -26,7 +26,7 @@ "@sentry/tracing": "7.17.3", "@sentry/types": "7.17.3", "@sentry/utils": "7.17.3", - "@sentry/webpack-plugin": "1.19.0", + "@sentry/webpack-plugin": "1.20.0", "chalk": "3.0.0", "rollup": "2.78.0", "tslib": "^1.9.3" diff --git a/packages/nextjs/src/config/webpack.ts b/packages/nextjs/src/config/webpack.ts index 659a1689273a..52a48e8d04f9 100644 --- a/packages/nextjs/src/config/webpack.ts +++ b/packages/nextjs/src/config/webpack.ts @@ -446,22 +446,6 @@ export function getWebpackPluginOptions( return { ...defaultPluginOptions, ...userPluginOptions }; } -/** - * NOTE: We're faking `require.resolve` here as a workaround for @vercel/nft detecting the binary itself as a hard - * dependency and always including it in the bundle, which is not what we want. - * - * ref: https://github.com/getsentry/sentry-javascript/issues/3865 - * ref: https://github.com/vercel/nft/issues/203 - */ -function ensureCLIBinaryExists(): boolean { - for (const node_modulesPath of module.paths) { - if (fs.existsSync(path.resolve(node_modulesPath, '@sentry/cli/sentry-cli'))) { - return true; - } - } - return false; -} - /** Check various conditions to decide if we should run the plugin */ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions: UserSentryOptions): boolean { const { isServer, dev: isDev } = buildContext; @@ -469,13 +453,11 @@ function shouldEnableWebpackPlugin(buildContext: BuildContext, userSentryOptions /** Non-negotiable */ - // TODO: this is a hack to fix https://github.com/getsentry/sentry-cli/issues/1085, which is caused by - // https://github.com/getsentry/sentry-cli/issues/915. Once the latter is addressed, this existence check can come - // out. (The check is necessary because currently, `@sentry/cli` uses a post-install script to download an + // This check is necessary because currently, `@sentry/cli` uses a post-install script to download an // architecture-specific version of the `sentry-cli` binary. If `yarn install`, `npm install`, or `npm ci` are run // with the `--ignore-scripts` option, this will be blocked and the missing binary will cause an error when users - // try to build their apps.) - if (!ensureCLIBinaryExists()) { + // try to build their apps. + if (!SentryWebpackPlugin.cliBinaryExists()) { return false; } diff --git a/yarn.lock b/yarn.lock index e7732a741fdf..216373f052f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4332,6 +4332,19 @@ proxy-from-env "^1.1.0" which "^2.0.2" +"@sentry/cli@^1.74.6": + version "1.74.6" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.74.6.tgz#c4f276e52c6f5e8c8d692845a965988068ebc6f5" + integrity sha512-pJ7JJgozyjKZSTjOGi86chIngZMLUlYt2HOog+OJn+WGvqEkVymu8m462j1DiXAnex9NspB4zLLNuZ/R6rTQHg== + dependencies: + https-proxy-agent "^5.0.0" + mkdirp "^0.5.5" + node-fetch "^2.6.7" + npmlog "^4.1.2" + progress "^2.0.3" + proxy-from-env "^1.1.0" + which "^2.0.2" + "@sentry/webpack-plugin@1.19.0": version "1.19.0" resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.19.0.tgz#2b134318f1552ba7f3e3f9c83c71a202095f7a44" @@ -4339,6 +4352,14 @@ dependencies: "@sentry/cli" "^1.74.4" +"@sentry/webpack-plugin@1.20.0": + version "1.20.0" + resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.20.0.tgz#e7add76122708fb6b4ee7951294b521019720e58" + integrity sha512-Ssj1mJVFsfU6vMCOM2d+h+KQR7QHSfeIP16t4l20Uq/neqWXZUQ2yvQfe4S3BjdbJXz/X4Rw8Hfy1Sd0ocunYw== + dependencies: + "@sentry/cli" "^1.74.6" + webpack-sources "^2.0.0 || ^3.0.0" + "@simple-dom/interface@^1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@simple-dom/interface/-/interface-1.4.0.tgz#e8feea579232017f89b0138e2726facda6fbb71f" @@ -25532,16 +25553,16 @@ webpack-sources@1.4.3, webpack-sources@^1.1.0, webpack-sources@^1.2.0, webpack-s source-list-map "^2.0.0" source-map "~0.6.1" +"webpack-sources@^2.0.0 || ^3.0.0", webpack-sources@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + webpack-sources@^3.2.2: version "3.2.2" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.2.tgz#d88e3741833efec57c4c789b6010db9977545260" integrity sha512-cp5qdmHnu5T8wRg2G3vZZHoJPN14aqQ89SyQ11NpGH5zEMDCclt49rzo+MaRazk7/UeILhAI+/sEtcM+7Fr0nw== -webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== - webpack-subresource-integrity@1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/webpack-subresource-integrity/-/webpack-subresource-integrity-1.4.1.tgz#e8bf918b444277df46a66cd84542cbcdc5a6272d"