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: Prevent @vercel/nft and similar tools from including binary file in their bundles #1207

Merged
merged 1 commit into from
Apr 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions js/helper.js
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down