Split plugins into their own packages
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.
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.
using the serverless-esbuild plugin this seemed to work for us in our serverless.yml file
custom:
esbuild:
external:
- graphql
@rochdev is there a ticket / issue we can follow perhaps while the work you mentioned gets worked on?
@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.
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.