From d535a51f5fb6de2d6b3fcecb811748d0f5653638 Mon Sep 17 00:00:00 2001 From: Thomas Hunter II Date: Thu, 11 Jun 2026 12:06:19 -0700 Subject: [PATCH 1/4] node.js webpack experimental support --- .../trace_collection/dd_libraries/nodejs.md | 62 +++++++++++++++++-- 1 file changed, 57 insertions(+), 5 deletions(-) diff --git a/content/en/tracing/trace_collection/dd_libraries/nodejs.md b/content/en/tracing/trace_collection/dd_libraries/nodejs.md index b8882c38692..f3f505f2139 100644 --- a/content/en/tracing/trace_collection/dd_libraries/nodejs.md +++ b/content/en/tracing/trace_collection/dd_libraries/nodejs.md @@ -153,11 +153,11 @@ Datadog recommends you have custom-built bundler plugins. These plugins are able **Note**: Some applications can have 100% of modules bundled, however native modules still need to remain external to the bundle. -#### Bundling with esbuild +#### Bundling with ESBuild -This library provides experimental esbuild support in the form of an esbuild plugin, and requires at least Node.js v16.17 or v18.7. To use the plugin, make sure you have `dd-trace@3+` installed, and then require the `dd-trace/esbuild` module when building your bundle. +This library provides ESBuild support in the form of an ESBuild plugin, and requires at least Node.js v16.17 or v18.7. To use the plugin, make sure you have `dd-trace@3+` installed, and then require the `dd-trace/esbuild` module when building your bundle. -Here's an example of how one might use `dd-trace` with esbuild: +Here's an example of how one might use `dd-trace` with ESBuild: ```javascript const ddPlugin = require('dd-trace/esbuild') @@ -188,10 +188,62 @@ esbuild.build({ }) ``` +**Note**: Every application is different and you may need to experiment with the list of `external` packages. + +#### Bundling with Webpack + +This library provides experimental Webpack support in the form of a Webpack plugin. To use the plugin, make sure you have `dd-trace@5.94.0+` installed, and then require the `dd-trace/webpack` module when building your bundle. + +Here's an example of how one might use `dd-trace` with Webpack: + +```javascript +const path = require('path') +const webpack = require('webpack') +const DatadogWebpackPlugin = require('dd-trace/webpack') + +const compiler = webpack({ + entry: 'main.js', + target: 'node', + externalsType: 'commonjs', + output: { + filename: 'out.js', + path: __dirname, + hashFunction: 'sha256', + }, + externals: [ + // Node.js built-in not in Webpack's default list for target: 'node' + 'diagnostics_channel', + + // dead code paths introduced by knex + 'pg', + 'mysql2', + 'better-sqlite3', + 'sqlite3', + 'mysql', + 'oracledb', + 'pg-query-stream', + 'tedious', + '@yaacovcr/transform', + + // optional native dd-trace modules + '@datadog/native-appsec', + '@datadog/native-iast-taint-tracking', + '@datadog/native-metrics', + '@datadog/pprof', + '@datadog/libdatadog', + ], + plugins: [ + new DatadogWebpackPlugin(), + ], +}) +``` + +**Note**: Every application is different and you may need to experiment with the list of `externals` packages. + #### Bundling with Next.js -If you are using Next.js or another framework relying on webpack to bundle your application, add a declaration -similar to the one for webpack inside your `next.config.js` configuration file: +If you are using Next.js to bundle your application, add a declaration +similar to the one for Webpack inside your `next.config.js` configuration file: ```javascript /** @type {import('next').NextConfig} */ From 78883762f8d8232fa52145125fd710430ef67e60 Mon Sep 17 00:00:00 2001 From: Thomas Hunter II Date: Thu, 11 Jun 2026 13:44:40 -0700 Subject: [PATCH 2/4] Update content/en/tracing/trace_collection/dd_libraries/nodejs.md Co-authored-by: Eva Parish --- content/en/tracing/trace_collection/dd_libraries/nodejs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/tracing/trace_collection/dd_libraries/nodejs.md b/content/en/tracing/trace_collection/dd_libraries/nodejs.md index f3f505f2139..fd96d1ed386 100644 --- a/content/en/tracing/trace_collection/dd_libraries/nodejs.md +++ b/content/en/tracing/trace_collection/dd_libraries/nodejs.md @@ -194,7 +194,7 @@ esbuild.build({ This library provides experimental Webpack support in the form of a Webpack plugin. To use the plugin, make sure you have `dd-trace@5.94.0+` installed, and then require the `dd-trace/webpack` module when building your bundle. -Here's an example of how one might use `dd-trace` with Webpack: +The following example shows how to use `dd-trace` with Webpack: ```javascript const path = require('path') From dab0ba0212574d3093e5023b5e90cc7284b76a64 Mon Sep 17 00:00:00 2001 From: Thomas Hunter II Date: Thu, 11 Jun 2026 13:53:54 -0700 Subject: [PATCH 3/4] ESBuild -> esbuild --- content/en/tracing/trace_collection/dd_libraries/nodejs.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/en/tracing/trace_collection/dd_libraries/nodejs.md b/content/en/tracing/trace_collection/dd_libraries/nodejs.md index fd96d1ed386..a7844bc00b0 100644 --- a/content/en/tracing/trace_collection/dd_libraries/nodejs.md +++ b/content/en/tracing/trace_collection/dd_libraries/nodejs.md @@ -153,11 +153,11 @@ Datadog recommends you have custom-built bundler plugins. These plugins are able **Note**: Some applications can have 100% of modules bundled, however native modules still need to remain external to the bundle. -#### Bundling with ESBuild +#### Bundling with esbuild -This library provides ESBuild support in the form of an ESBuild plugin, and requires at least Node.js v16.17 or v18.7. To use the plugin, make sure you have `dd-trace@3+` installed, and then require the `dd-trace/esbuild` module when building your bundle. +This library provides esbuild support in the form of an esbuild plugin, and requires at least Node.js v16.17 or v18.7. To use the plugin, make sure you have `dd-trace@3+` installed, and then require the `dd-trace/esbuild` module when building your bundle. -Here's an example of how one might use `dd-trace` with ESBuild: +Here's an example of how one might use `dd-trace` with esbuild: ```javascript const ddPlugin = require('dd-trace/esbuild') From 6665032af5139296327c8eac1012d1f466dac74e Mon Sep 17 00:00:00 2001 From: Thomas Hunter II Date: Fri, 12 Jun 2026 11:43:10 -0700 Subject: [PATCH 4/4] remove notes --- content/en/tracing/trace_collection/dd_libraries/nodejs.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/content/en/tracing/trace_collection/dd_libraries/nodejs.md b/content/en/tracing/trace_collection/dd_libraries/nodejs.md index a7844bc00b0..b99bfb9bfe5 100644 --- a/content/en/tracing/trace_collection/dd_libraries/nodejs.md +++ b/content/en/tracing/trace_collection/dd_libraries/nodejs.md @@ -188,8 +188,6 @@ esbuild.build({ }) ``` -**Note**: Every application is different and you may need to experiment with the list of `external` packages. - #### Bundling with Webpack This library provides experimental Webpack support in the form of a Webpack plugin. To use the plugin, make sure you have `dd-trace@5.94.0+` installed, and then require the `dd-trace/webpack` module when building your bundle. @@ -238,8 +236,6 @@ const compiler = webpack({ }) ``` -**Note**: Every application is different and you may need to experiment with the list of `externals` packages. - #### Bundling with Next.js If you are using Next.js to bundle your application, add a declaration