From ed1a6914755e5b99e6e31d199e4e6d248152c76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Og=C3=B3rek?= Date: Tue, 26 Apr 2022 11:33:11 +0200 Subject: [PATCH] ref: Prevent @vercel/nft and similar tools from including binary file in their bundles --- js/helper.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/js/helper.js b/js/helper.js index 787c000251..6ac1c37ab2 100644 --- a/js/helper.js +++ b/js/helper.js @@ -1,19 +1,22 @@ 'use strict'; const childProcess = require('child_process'); -const os = require('os'); -const path = require('path'); /** * Absolute path to the sentry-cli binary (platform dependent). * @type {string} */ -// istanbul ignore next -let binaryPath = path.resolve( - __dirname, - - os.platform() === 'win32' ? '..\\sentry-cli.exe' : '../sentry-cli' +let binaryPath = eval( + "require('path').resolve(__dirname, require('os').platform() === 'win32' ? '..\\sentry-cli.exe' : '../sentry-cli')" ); + +/** + * NOTE: `eval` usage is a workaround for @vercel/nft detecting the binary itself as the hard dependency + * and effectively 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 + */ + /** * Overrides the default binary path with a mock value, useful for testing. *