dd-trace-js icon indicating copy to clipboard operation
dd-trace-js copied to clipboard

Split plugins into their own packages

Open jpike88 opened this issue 3 years ago • 4 comments

Building a nodejs app with esbuild as causing esbuild to get confused by the plugins in dd-trace (e.g. it expects graphql lib to be present even though its just mentioned in a plugin and I don't want to use it).

Would be more appropriate to bundle plugins separately, only include what's needed.

jpike88 avatar Jan 11 '22 15:01 jpike88

It should be enough to tell the bundler that the dependency is external. I don't know how to do this with ESBuild but this is how it would be done with Webpack.

Ideally this wouldn't be needed, but we're not ready yet to split dd-trace apart, although it is planned in the future. We do plan however to support ESBuild soon so this might be something we're able to work around out of the box in the next few months.

rochdev avatar Jan 11 '22 16:01 rochdev

using the serverless-esbuild plugin this seemed to work for us in our serverless.yml file

custom:
  esbuild:
    external:
      - graphql

sunsheeppoplar avatar May 21 '22 00:05 sunsheeppoplar

@rochdev is there a ticket / issue we can follow perhaps while the work you mentioned gets worked on?

sunsheeppoplar avatar May 21 '22 00:05 sunsheeppoplar

@sunsheeppoplar Unfortunately all planning is done internally and is not available publicly. We're not currently working on this but we still plan to work on it at some point. In the meantime we recommend to do what you did above and prevent dependencies from being bundled, or at the very least the dependencies that we instrument.

rochdev avatar May 30 '22 16:05 rochdev

FYI, we did land official esbuild support. Please try the new plugin and see if it helps: https://docs.datadoghq.com/tracing/trace_collection/automatic_instrumentation/dd_libraries/nodejs/#esbuild-support

If the graphql stuff is still an issue you can add this to your esbuild config:

external: [
  'graphql/language/visitor',
  'graphql/language/printer',
  'graphql/utilities',
],

I'll close this ticket for now but if the official plugin doesn't help feeel free to tag me and reopen.

tlhunter avatar Dec 18 '23 20:12 tlhunter