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

feat: enable ESM support for Node v20 #3469

wants to merge 2 commits into from

Conversation

trentm
Copy link
Member

@trentm trentm commented Jul 6, 2023

All the hard work was done in import-in-the-middle#28.

Refs: #3445

All the hard work was done in import-in-the-middle#28.

Refs: #3445
@trentm trentm self-assigned this Jul 6, 2023
@trentm trentm mentioned this pull request Jul 6, 2023
40 tasks
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Jul 6, 2023
@elastic-apm-tech elastic-apm-tech added this to In Progress in APM-Agents (OLD) Jul 6, 2023
Also had to uninstall/reinstall some dev deps because `npm` was unable
to resolve where to correctly place 'acorn' (which has usage of @8 and
@7 by various other deps) and 'acorn-import-assertions' (which has a
peerDep on acorn@8). This unforunately resulted in updating some
transitive deps, so it muddies the package-lock change somewhat.
@trentm
Copy link
Member Author

trentm commented Jul 6, 2023

That fails the ESM test attempting to use @aws-sdk/client-s3. For example:

% ELASTIC_APM_CAPTURE_EXCEPTIONS=false node --experimental-loader=./loader.mjs --require=./start.js test/instrumentation/modules/@aws-sdk/fixtures/use-client-s3.mjs
{"log.level":"info","@timestamp":"2023-07-06T16:44:02.196Z","log":{"logger":"elastic-apm-node"},"agentVersion":"3.47.0","env":{"pid":7511,"proctitle":"node","os":"darwin 22.5.0","arch":"x64","host":"pink.local","timezone":"UTC-0700","runtime":"Node.js v20.2.0"},"config":{"serviceName":{"source":"default","value":"elastic-apm-node","commonName":"service_name"},"serviceVersion":{"source":"default","value":"3.47.0","commonName":"service_version"},"serverUrl":{"source":"default","value":"http://127.0.0.1:8200/","commonName":"server_url"},"logLevel":{"source":"default","value":"info","commonName":"log_level"},"captureExceptions":{"source":"environment","value":false,"sourceValue":"false"}},"activationMethod":"preload","ecs":{"version":"1.6.0"},"message":"Elastic APM Node.js Agent v3.47.0"}
(node:7511) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///Users/trentm/el/apm-agent-nodejs8/test/instrumentation/modules/@aws-sdk/fixtures/use-client-s3.mjs:19
  ListBucketsCommand
  ^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@aws-sdk/client-s3' does not provide an export named 'ListBucketsCommand'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:122:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:188:5)

Node.js v20.2.0

This is an import-in-the-middle issue, though I'm not exactly sure how tractable this will be in general. I've opened DataDog/import-in-the-middle#29

@trentm trentm marked this pull request as draft July 6, 2023 16:45
@trentm trentm moved this from In Progress to Blocked in APM-Agents (OLD) Jul 6, 2023
@trentm
Copy link
Member Author

trentm commented Aug 9, 2023

Note that we'll be updating to import-in-the-middle@1.4.2 in #3569 so this PR will need to be adjusted when we want to enable using node v20 and ESM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
APM-Agents (OLD)
  
Blocked
Development

Successfully merging this pull request may close these issues.

None yet

1 participant