|
1 | 1 | import { arch as _arch, platform as _platform } from 'node:os';
|
2 |
| -import { join, resolve } from 'node:path'; |
| 2 | +import { join, resolve} from 'node:path'; |
3 | 3 | import { env, versions } from 'node:process';
|
4 | 4 | import { threadId } from 'node:worker_threads';
|
5 | 5 | import { familySync } from 'detect-libc';
|
@@ -27,17 +27,13 @@ const arch = process.env['BUILD_ARCH'] || _arch();
|
27 | 27 | const abi = getAbi(versions.node, 'node');
|
28 | 28 | const identifier = [platform, arch, stdlib, abi].filter(c => c !== undefined && c !== null).join('-');
|
29 | 29 |
|
30 |
| -const built_from_source_path = resolve(__dirname, '..', `./sentry_cpu_profiler-${identifier}`); |
31 |
| - |
32 | 30 | /**
|
33 | 31 | * Imports cpp bindings based on the current platform and architecture.
|
34 | 32 | */
|
35 | 33 | // eslint-disable-next-line complexity
|
36 | 34 | export function importCppBindingsModule(): PrivateV8CpuProfilerBindings {
|
37 | 35 | // #START_SENTRY_ESM_REQUIRE_SHIM
|
38 |
| - // When building for ESM, we shim require to use createRequire and __dirname. |
39 |
| - // We need to do this because .node extensions in esm are not supported. |
40 |
| - // The comment below this line exists as a placeholder for where to insert the shim. |
| 36 | + // When building for ESM, we shim require to use createRequire because .node extensions in esm are not supported. |
41 | 37 | // #END_SENTRY_ESM_REQUIRE_SHIM
|
42 | 38 |
|
43 | 39 | // If a binary path is specified, use that.
|
@@ -165,6 +161,12 @@ export function importCppBindingsModule(): PrivateV8CpuProfilerBindings {
|
165 | 161 | }
|
166 | 162 | }
|
167 | 163 | }
|
| 164 | + |
| 165 | + // #START_SENTRY_ESM_DIRNAME_SHIM |
| 166 | + // const filename = fileURLToPath(import.meta.url); |
| 167 | + // const __dirname = dirname(filename); |
| 168 | + // #END_SENTRY_ESM_DIRNAME_SHIM |
| 169 | + const built_from_source_path = resolve(__dirname, '..', `./sentry_cpu_profiler-${identifier}`); |
168 | 170 | return require(`${built_from_source_path}.node`);
|
169 | 171 | }
|
170 | 172 |
|
|
0 commit comments