Skip to content

Commit

Permalink
massively lost
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Dec 12, 2024
1 parent fd618e9 commit 31653f3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
`,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,5 +30,5 @@ Sentry.startSpan({ name: 'Precompile test' }, async () => {
await wait(500);
});

assertUnpatechedRequire();
assertUnpatchedRequire();
console.log('✅ Require is not patched');
3 changes: 1 addition & 2 deletions packages/profiling-node/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions packages/profiling-node/src/cpu_profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}

Expand Down

0 comments on commit 31653f3

Please sign in to comment.