Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable ESM support for Node v20 #3469

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev-utils/gen-notice.sh
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@ npm ls --omit=dev --all --parseable \
// We handle getting the license text for a few specific deps that
// do not include one in their install.
const licFileFromPkgName = {
"acorn-import-assertions": "license.MIT.txt",
"async-value": "license.MIT.txt",
"async-value-promise": "license.MIT.txt",
"breadth-filter": "license.MIT.txt",
2 changes: 1 addition & 1 deletion docs/esm.asciidoc
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ As well, the APM agent must also be separately *started* -- for example via `--r

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.

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.
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.


[float]
603 changes: 302 additions & 301 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@
"escape-string-regexp": "^4.0.0",
"fast-safe-stringify": "^2.0.7",
"http-headers": "^3.0.2",
"import-in-the-middle": "1.3.5",
"import-in-the-middle": "1.4.1",
"is-native": "^1.0.1",
"lru-cache": "^6.0.0",
"measured-reporting": "^1.51.1",
2 changes: 1 addition & 1 deletion test/instrumentation/modules/fastify/fastify.test.js
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ const testFixtures = [
ELASTIC_APM_CAPTURE_BODY: 'all'
},
versionRanges: {
node: '^14.13.1 || ^16.0.0 || ^18.1.0 <20', // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
node: '^14.13.1 || ^16.0.0 || >=18.1.0', // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
// IITM and `import fastify from 'fastify'` fail without https://github.com/fastify/fastify/pull/2590
// I would have thought the only failure would be with a named import,
// so I don't completely understand the issue.
4 changes: 2 additions & 2 deletions test/instrumentation/modules/http/http-esm.test.js
Original file line number Diff line number Diff line change
@@ -92,7 +92,7 @@ const testFixtures = [
ELASTIC_APM_USE_PATH_AS_TRANSACTION_NAME: 'true'
},
versionRanges: {
node: '^14.13.1 || ^16.0.0 || ^18.1.0 <20' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
node: '^14.13.1 || ^16.0.0 || >=18.1.0' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
},
verbose: false,
checkApmServer: (t, apmServer) => {
@@ -113,7 +113,7 @@ const testFixtures = [
NODE_NO_WARNINGS: '1' // skip warnings about --experimental-loader
},
versionRanges: {
node: '^14.13.1 || ^16.0.0 || ^18.1.0 <20' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
node: '^14.13.1 || ^16.0.0 || >=18.1.0' // NODE_VER_RANGE_IITM minus node v12 because top-level `await` is used
},
verbose: true
}
4 changes: 1 addition & 3 deletions test/testconsts.js
Original file line number Diff line number Diff line change
@@ -13,9 +13,7 @@
// fixes in the .1 minor release
// - v18.1.0 fixes an issue in v18.0.0
// https://github.com/nodejs/node/pull/42881
// - Current node v20 does not work with IITM
// https://github.com/DataDog/import-in-the-middle/pull/27
const NODE_VER_RANGE_IITM = '^12.20.0 || ^14.13.1 || ^16.0.0 || ^18.1.0 <20'
const NODE_VER_RANGE_IITM = '^12.20.0 || ^14.13.1 || ^16.0.0 || >=18.1.0'

module.exports = {
NODE_VER_RANGE_IITM