Skip to content

Commit 93ddb85

Browse files
committed
feat: enable ESM support for Node v20
All the hard work was done in import-in-the-middle#28. Refs: #3445
1 parent 39859db commit 93ddb85

File tree

6 files changed

+60
-15
lines changed

6 files changed

+60
-15
lines changed

docs/esm.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ As well, the APM agent must also be separately *started* -- for example via `--r
7070

7171
Automatic instrumentation of ES modules is based on the experimental Node.js Loaders API. ESM support in the Elastic APM Node.js agent will remain *experimental* while the Loaders API is experimental.
7272

73-
ESM auto-instrumentation is only supported for Node.js versions that match *`^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 <20`*. Notably, in the current APM agent version, this _excludes Node.js v20_ because of changes in the Loaders API. The behavior when using `node --experimental-loader=elastic-apm-node/loader.mjs` with earlier Node.js versions is undefined and unsupported.
73+
ESM auto-instrumentation is only supported for Node.js versions that match *`^12.20.0 || ^14.13.1 || ^16.0.0 || >=18.1.0`*. The behavior when using `node --experimental-loader=elastic-apm-node/loader.mjs` with earlier Node.js versions is undefined and unsupported.
7474

7575

7676
[float]

package-lock.json

+54-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"escape-string-regexp": "^4.0.0",
103103
"fast-safe-stringify": "^2.0.7",
104104
"http-headers": "^3.0.2",
105-
"import-in-the-middle": "1.3.5",
105+
"import-in-the-middle": "1.4.1",
106106
"is-native": "^1.0.1",
107107
"lru-cache": "^6.0.0",
108108
"measured-reporting": "^1.51.1",

test/instrumentation/modules/fastify/fastify.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const testFixtures = [
4848
ELASTIC_APM_CAPTURE_BODY: 'all'
4949
},
5050
versionRanges: {
51-
node: '^14.13.1 || ^16.0.0 || ^18.1.0 <20', // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
51+
node: '^14.13.1 || ^16.0.0 || >=18.1.0', // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
5252
// IITM and `import fastify from 'fastify'` fail without https://github.com/fastify/fastify/pull/2590
5353
// I would have thought the only failure would be with a named import,
5454
// so I don't completely understand the issue.

test/instrumentation/modules/http/http-esm.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const testFixtures = [
9292
ELASTIC_APM_USE_PATH_AS_TRANSACTION_NAME: 'true'
9393
},
9494
versionRanges: {
95-
node: '^14.13.1 || ^16.0.0 || ^18.1.0 <20' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
95+
node: '^14.13.1 || ^16.0.0 || >=18.1.0' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
9696
},
9797
verbose: false,
9898
checkApmServer: (t, apmServer) => {
@@ -113,7 +113,7 @@ const testFixtures = [
113113
NODE_NO_WARNINGS: '1' // skip warnings about --experimental-loader
114114
},
115115
versionRanges: {
116-
node: '^14.13.1 || ^16.0.0 || ^18.1.0 <20' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
116+
node: '^14.13.1 || ^16.0.0 || >=18.1.0' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
117117
},
118118
verbose: true
119119
}

test/testconsts.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
// fixes in the .1 minor release
1414
// - v18.1.0 fixes an issue in v18.0.0
1515
// https://github.com/nodejs/node/pull/42881
16-
// - Current node v20 does not work with IITM
17-
// https://github.com/DataDog/import-in-the-middle/pull/27
18-
const NODE_VER_RANGE_IITM = '^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 <20'
16+
const NODE_VER_RANGE_IITM = '^12.20.0 || ^14.13.1 || ^16.0.0 || >=18.1.0'
1917

2018
module.exports = {
2119
NODE_VER_RANGE_IITM

0 commit comments

Comments
 (0)