From 4d464018288717fd0301f12fc38bd68ad93161d1 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Thu, 12 Dec 2024 13:46:58 +0000 Subject: [PATCH] massively lost --- .../test-applications/node-profiling/build.shimmed.mjs | 10 ---------- .../test-applications/node-profiling/index.mjs | 4 ++-- .../test-applications/node-profiling/package.json | 6 +++--- packages/profiling-node/rollup.npm.config.mjs | 3 +-- packages/profiling-node/src/cpu_profiler.ts | 5 ++--- 5 files changed, 8 insertions(+), 20 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/node-profiling/build.shimmed.mjs b/dev-packages/e2e-tests/test-applications/node-profiling/build.shimmed.mjs index c45e30539bc0..1328eb1a5b04 100644 --- a/dev-packages/e2e-tests/test-applications/node-profiling/build.shimmed.mjs +++ b/dev-packages/e2e-tests/test-applications/node-profiling/build.shimmed.mjs @@ -16,14 +16,4 @@ esbuild.buildSync({ format: 'esm', bundle: true, loader: { '.node': 'copy' }, - banner: { - js: ` - import { dirname } from 'node:path'; - import { fileURLToPath } from 'node:url'; - import { createRequire } from 'node:module'; - const require = createRequire(import.meta.url); - const __filename = fileURLToPath(import.meta.url); - const __dirname = dirname(__filename); - `, - }, }); diff --git a/dev-packages/e2e-tests/test-applications/node-profiling/index.mjs b/dev-packages/e2e-tests/test-applications/node-profiling/index.mjs index 71608ef53260..bd178eb0f716 100644 --- a/dev-packages/e2e-tests/test-applications/node-profiling/index.mjs +++ b/dev-packages/e2e-tests/test-applications/node-profiling/index.mjs @@ -8,7 +8,7 @@ console.log('🧵 Starting ESM test'); const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); -function assertUnpatechedRequire() { +function assertUnpatchedRequire() { if (typeof require !== 'undefined') { // Test that globalThis.require is not defined by any side effects of the profiling // https://github.com/getsentry/sentry-javascript/issues/13662 @@ -30,5 +30,5 @@ Sentry.startSpan({ name: 'Precompile test' }, async () => { await wait(500); }); -assertUnpatechedRequire(); +assertUnpatchedRequire(); console.log('✅ Require is not patched'); diff --git a/dev-packages/e2e-tests/test-applications/node-profiling/package.json b/dev-packages/e2e-tests/test-applications/node-profiling/package.json index 2029ac1370ed..14dfb2d16fd3 100644 --- a/dev-packages/e2e-tests/test-applications/node-profiling/package.json +++ b/dev-packages/e2e-tests/test-applications/node-profiling/package.json @@ -5,12 +5,12 @@ "scripts": { "typecheck": "tsc --noEmit", "build": "node build.mjs && node build.shimmed.mjs", - "test": "node dist/index.js && node --experimental-require-module dist/index.js && node dist/index.shimmed.mjs", "clean": "npx rimraf node_modules dist", + "test": "node dist/index.js && node --experimental-require-module dist/index.js && node dist/index.shimmed.mjs", + "test:mjs": "node index.mjs", "test:electron": "$(pnpm bin)/electron-rebuild && playwright test", "test:build": "pnpm run typecheck && pnpm run build", - "test:assert": "pnpm run test && pnpm run test:electron", - "test:mjs": "node index.mjs" + "test:assert": "pnpm run test:mjs && pnpm run test && pnpm run test:electron" }, "dependencies": { "@electron/rebuild": "^3.7.0", diff --git a/packages/profiling-node/rollup.npm.config.mjs b/packages/profiling-node/rollup.npm.config.mjs index c0da1ddb3e24..47a5f0843951 100644 --- a/packages/profiling-node/rollup.npm.config.mjs +++ b/packages/profiling-node/rollup.npm.config.mjs @@ -12,8 +12,7 @@ const require = createRequire(import.meta.url); `; const ESMDirnameShim = ` -const filename = fileURLToPath(import.meta.url); -const __dirname = dirname(__filename); +const __dirname = dirname(fileURLToPath(import.meta.url)); `; function makeESMImportShimPlugin(shim) { diff --git a/packages/profiling-node/src/cpu_profiler.ts b/packages/profiling-node/src/cpu_profiler.ts index bbdf2c621844..b9a4acd722be 100644 --- a/packages/profiling-node/src/cpu_profiler.ts +++ b/packages/profiling-node/src/cpu_profiler.ts @@ -164,10 +164,9 @@ export function importCppBindingsModule(): PrivateV8CpuProfilerBindings { } // #START_SENTRY_ESM_DIRNAME_SHIM - // const filename = fileURLToPath(import.meta.url); - // const __dirname = dirname(filename); + // const __dirname = dirname(fileURLToPath(import.meta.url)); // #END_SENTRY_ESM_DIRNAME_SHIM - const built_from_source_path = resolve(__dirname, '..', `./sentry_cpu_profiler-${identifier}`); + const built_from_source_path = resolve(__dirname, '..', `sentry_cpu_profiler-${identifier}`); return require(`${built_from_source_path}.node`); }