Open BryanHunt opened 1 year ago
Any chance we can get a release with this fix?
FYI after the big recent refactor, this now requires all relative paths (there are many more now) to end in .js.
Same here for node v20, ESM, typescript. Any fix available?
If that helps anyone, here's a patch that applies to the built version of version 0.3.11 (can be used with npm/pnpm patch):
diff --git a/dist/esm/express/middleware.js b/dist/esm/express/middleware.js
index 135754317f3810fc0d2b59db6c69ebd3c10e48ad..1886f7d1afb26077d80cd4aca2a8ab366d8a4b17 100644
--- a/dist/esm/express/middleware.js
+++ b/dist/esm/express/middleware.js
@@ -1,5 +1,5 @@
import debug from 'debug';
-import { getProfiler } from '../utils/pyroscope-profiler';
+import { getProfiler } from '../utils/pyroscope-profiler.js';
import { encode } from '@datadog/pprof';
const log = debug('pyroscope');
async function collectProfile(profiler) {
diff --git a/dist/esm/index.js b/dist/esm/index.js
index b80769c765a85af1b88f3d76bd42bbbd6122719f..0a509e604b2539184fb7f8bde7532b0e74fefbe1 100644
--- a/dist/esm/index.js
+++ b/dist/esm/index.js
@@ -1,13 +1,13 @@
-import 'regenerator-runtime/runtime';
-import expressMiddleware from './express/middleware';
-import { PyroscopeProfiler } from './profilers/pyroscope-profiler';
-import { checkPyroscopeConfig } from './utils/check-pyroscope-config';
-import { getProfiler, setProfiler } from './utils/pyroscope-profiler';
-import { processConfig } from './utils/process-config';
-import { getEnv } from './utils/get-env';
+import 'regenerator-runtime/runtime.js';
+import expressMiddleware from './express/middleware.js';
+import { PyroscopeProfiler } from './profilers/pyroscope-profiler.js';
+import { checkPyroscopeConfig } from './utils/check-pyroscope-config.js';
+import { getProfiler, setProfiler } from './utils/pyroscope-profiler.js';
+import { processConfig } from './utils/process-config.js';
+import { getEnv } from './utils/get-env.js';
import { setLogger as datadogSetLogger } from '@datadog/pprof';
-import { setLogger as ourSetLogger } from './logger';
-import { SourceMapper } from './sourcemapper';
+import { setLogger as ourSetLogger } from './logger.js';
+import { SourceMapper } from './sourcemapper.js';
export function init(config = {}) {
checkPyroscopeConfig(config);
const processedConfig = processConfig(config, getEnv());
diff --git a/dist/esm/profilers/pyroscope-profiler.js b/dist/esm/profilers/pyroscope-profiler.js
index f6c5720ee650f17fe27373a0eb4edd88644fda76..e5f7f63037a304a3cca896348904669b7ef20f65 100644
--- a/dist/esm/profilers/pyroscope-profiler.js
+++ b/dist/esm/profilers/pyroscope-profiler.js
@@ -1,7 +1,7 @@
-import { PyroscopeApiExporter } from '../pyroscope-api-exporter';
-import { ContinuousProfiler } from './continuous-profiler';
-import { WallProfiler } from './wall-profiler';
-import { HeapProfiler } from './heap-profiler';
+import { PyroscopeApiExporter } from '../pyroscope-api-exporter.js';
+import { ContinuousProfiler } from './continuous-profiler.js';
+import { WallProfiler } from './wall-profiler.js';
+import { HeapProfiler } from './heap-profiler.js';
const MICROS_PER_SECOND = 1e6;
const MS_PER_SECOND = 1e3;
const B_PER_MB = 1024;
diff --git a/dist/esm/pyroscope-api-exporter.js b/dist/esm/pyroscope-api-exporter.js
index 98c411275c9b9b9a67f1505e23b9f9953d298e61..5f83c95a43031356c6c96d7622beda16a116cc73 100644
--- a/dist/esm/pyroscope-api-exporter.js
+++ b/dist/esm/pyroscope-api-exporter.js
@@ -2,8 +2,8 @@ import { URL } from 'node:url';
import { encode } from '@datadog/pprof';
import axios from 'axios';
import FormData from 'form-data';
-import { dateToUnixTimestamp } from './utils/date-to-unix-timestamp';
-import { processProfile } from './utils/process-profile';
+import { dateToUnixTimestamp } from './utils/date-to-unix-timestamp.js';
+import { processProfile } from './utils/process-profile.js';
import debug from 'debug';
const log = debug('pyroscope');
export class PyroscopeApiExporter {
diff --git a/dist/esm/sourcemapper.js b/dist/esm/sourcemapper.js
index 511afb642c04e2dcce220b2e5e29dec48475e9dd..73fa20d3845bb0011cfe2b04bd7cc8bc03d8f8a2 100644
--- a/dist/esm/sourcemapper.js
+++ b/dist/esm/sourcemapper.js
@@ -21,7 +21,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as sourceMap from 'source-map';
-import { logger } from './logger';
+import { logger } from './logger.js';
import pLimit from 'p-limit';
const readFile = fs.promises.readFile;
const CONCURRENCY = 10;
We are attempting to add Pyroscope to one of our NodeJS framework modules. Pyroscope fails to load with the following error:
We are running NodeJS v16.19.1 with the following mocha configuration:
Hacking the module and changing the import to:
seems to fix the problem.