Skip to content

Commit bd92bf2

Browse files
committed
ref: Prevent @vercel/nft and similar tools from including binary file in their bundles (#1207)
1 parent 279bfdc commit bd92bf2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

js/helper.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
'use strict';
22

33
const childProcess = require('child_process');
4-
const os = require('os');
5-
const path = require('path');
64

75
/**
86
* Absolute path to the sentry-cli binary (platform dependent).
97
* @type {string}
108
*/
11-
// istanbul ignore next
12-
let binaryPath = path.resolve(
13-
__dirname,
14-
15-
os.platform() === 'win32' ? '..\\sentry-cli.exe' : '../sentry-cli'
9+
let binaryPath = eval(
10+
"require('path').resolve(__dirname, require('os').platform() === 'win32' ? '..\\sentry-cli.exe' : '../sentry-cli')"
1611
);
12+
13+
/**
14+
* NOTE: `eval` usage is a workaround for @vercel/nft detecting the binary itself as the hard dependency
15+
* and effectively always including it in the bundle, which is not what we want.
16+
* ref: https://github.com/getsentry/sentry-javascript/issues/3865
17+
* ref: https://github.com/vercel/nft/issues/203
18+
*/
19+
1720
/**
1821
* Overrides the default binary path with a mock value, useful for testing.
1922
*

0 commit comments

Comments
 (0)