Skip to content

feat(bundler): experimental webpack bundling support#7647

Merged
tlhunter merged 1 commit intomasterfrom
tlhunter/webpack
Mar 26, 2026
Merged

feat(bundler): experimental webpack bundling support#7647
tlhunter merged 1 commit intomasterfrom
tlhunter/webpack

Conversation

@tlhunter
Copy link
Copy Markdown
Member

@tlhunter tlhunter commented Mar 2, 2026

Example Usage:

const webpack = require('webpack')
const DDWebpack = require('dd-trace/webpack')

const compiler = webpack({
  mode: 'development',
  entry: 'foo.js',
  target: 'node',
  externalsType: 'commonjs',
  output: {
    filename: 'bundle.js',
    hashFunction: 'sha256',
  },
  externals: [
    // Node built-in not in webpack's default list for target: 'node'
    'diagnostics_channel',
    // optional native dd-trace modules
    '@datadog/native-appsec',
    '@datadog/native-iast-taint-tracking',
    '@datadog/native-metrics',
    '@datadog/pprof',
    '@datadog/libdatadog',
  ],
  plugins: [
    new DDWebpack(),
  ],
})

@tlhunter tlhunter added semver-minor bundler AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos labels Mar 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 2, 2026

Overall package size

Self size: 5.05 MB
Deduped: 5.9 MB
No deduping: 5.9 MB

Dependency sizes | name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.0.0 | 81.15 kB | 815.98 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |

🤖 This report was automatically generated by heaviest-objects-in-the-universe

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented Mar 2, 2026

Benchmarks

Benchmark execution time: 2026-03-25 21:05:36

Comparing candidate commit 41905e7 in PR branch tlhunter/webpack with baseline commit a498993 in branch master.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 231 metrics, 29 unstable metrics.

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 3, 2026

Codecov Report

❌ Patch coverage is 48.03922% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.61%. Comparing base (a498993) to head (41905e7).

Files with missing lines Patch % Lines
packages/datadog-webpack/index.js 43.58% 44 Missing ⚠️
packages/datadog-webpack/src/log.js 54.54% 5 Missing ⚠️
...g-instrumentations/src/helpers/bundler-register.js 40.00% 3 Missing ⚠️
packages/dd-trace/src/plugin_manager.js 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7647      +/-   ##
==========================================
- Coverage   80.46%   74.61%   -5.85%     
==========================================
  Files         749      768      +19     
  Lines       32487    35661    +3174     
==========================================
+ Hits        26140    26610     +470     
- Misses       6347     9051    +2704     
Flag Coverage Δ
aiguard-macos 39.23% <50.00%> (-0.10%) ⬇️
aiguard-ubuntu 39.34% <50.00%> (-0.10%) ⬇️
aiguard-windows 39.01% <50.00%> (-0.10%) ⬇️
apm-capabilities-tracing-macos 49.10% <50.00%> (-0.01%) ⬇️
apm-capabilities-tracing-ubuntu 49.01% <50.00%> (-0.01%) ⬇️
apm-capabilities-tracing-windows 48.88% <50.00%> (-0.01%) ⬇️
apm-integrations-child-process 38.56% <50.00%> (-0.10%) ⬇️
apm-integrations-couchbase-18 37.36% <50.00%> (+0.04%) ⬆️
apm-integrations-couchbase-eol 37.84% <50.00%> (-0.10%) ⬇️
apm-integrations-oracledb 37.68% <50.00%> (-0.09%) ⬇️
appsec-express 55.16% <50.00%> (-0.09%) ⬇️
appsec-fastify 51.52% <50.00%> (-0.08%) ⬇️
appsec-graphql 51.68% <50.00%> (-0.07%) ⬇️
appsec-kafka 44.31% <50.00%> (-0.08%) ⬇️
appsec-ldapjs 43.93% <50.00%> (-0.08%) ⬇️
appsec-lodash 43.53% <50.00%> (-0.08%) ⬇️
appsec-macos 58.18% <50.00%> (-0.07%) ⬇️
appsec-mongodb-core 48.69% <50.00%> (-0.08%) ⬇️
appsec-mongoose 49.35% <50.00%> (-0.09%) ⬇️
appsec-mysql 50.79% <50.00%> (-0.08%) ⬇️
appsec-node-serialize 43.12% <50.00%> (-0.08%) ⬇️
appsec-passport 47.55% <50.00%> (-0.09%) ⬇️
appsec-postgres 50.51% <50.00%> (-0.08%) ⬇️
appsec-sourcing 42.37% <50.00%> (-0.09%) ⬇️
appsec-stripe 44.55% <50.00%> (-0.09%) ⬇️
appsec-template 43.28% <50.00%> (-0.08%) ⬇️
appsec-ubuntu 58.26% <50.00%> (-0.07%) ⬇️
appsec-windows 58.00% <50.00%> (-0.07%) ⬇️
instrumentations-instrumentation-bluebird 32.20% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-body-parser 40.45% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-child_process 37.90% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-cookie-parser 34.23% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-express 34.55% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-express-mongo-sanitize 34.36% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-express-session 40.09% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-fs 31.89% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-generic-pool 29.45% <40.00%> (+0.01%) ⬆️
instrumentations-instrumentation-http 39.80% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-knex 32.27% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-mongoose 33.39% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-multer 40.21% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-mysql2 38.23% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-passport 43.98% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-passport-http 43.65% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-passport-local 44.18% <50.00%> (-0.09%) ⬇️
instrumentations-instrumentation-pg 37.67% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-promise 32.13% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-promise-js 32.14% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-q 32.18% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-url 32.10% <50.00%> (-0.10%) ⬇️
instrumentations-instrumentation-when 32.15% <50.00%> (-0.10%) ⬇️
llmobs-ai 42.37% <50.00%> (-0.10%) ⬇️
llmobs-anthropic 40.38% <50.00%> (-0.09%) ⬇️
llmobs-bedrock 39.17% <50.00%> (-0.08%) ⬇️
llmobs-google-genai 39.71% <50.00%> (-0.09%) ⬇️
llmobs-langchain 40.07% <50.00%> (-0.08%) ⬇️
llmobs-openai 43.89% <50.00%> (-0.09%) ⬇️
llmobs-vertex-ai 39.96% <50.00%> (-0.09%) ⬇️
platform-core 31.47% <ø> (ø)
platform-esbuild 34.42% <ø> (ø)
platform-instrumentations-misc 48.41% <ø> (ø)
platform-shimmer 37.56% <ø> (ø)
platform-unit-guardrails 32.89% <ø> (ø)
platform-webpack 20.04% <48.03%> (?)
plugins-azure-durable-functions 25.74% <ø> (ø)
plugins-azure-event-hubs 25.90% <ø> (ø)
plugins-azure-service-bus 25.26% <ø> (ø)
plugins-bullmq 44.39% <50.00%> (+0.02%) ⬆️
plugins-cassandra 37.72% <50.00%> (-0.09%) ⬇️
plugins-cookie 26.96% <ø> (ø)
plugins-cookie-parser 26.75% <ø> (ø)
plugins-crypto 26.73% <ø> (ø)
plugins-dd-trace-api 38.25% <50.00%> (-0.10%) ⬇️
plugins-express-mongo-sanitize 26.89% <ø> (ø)
plugins-express-session 26.70% <ø> (ø)
plugins-fastify 42.17% <50.00%> (-0.09%) ⬇️
plugins-fetch 38.34% <50.00%> (-0.09%) ⬇️
plugins-fs 38.58% <50.00%> (-0.10%) ⬇️
plugins-generic-pool 25.94% <ø> (ø)
plugins-google-cloud-pubsub 45.48% <50.00%> (-0.09%) ⬇️
plugins-grpc 40.84% <50.00%> (-0.09%) ⬇️
plugins-handlebars 26.94% <ø> (ø)
plugins-hapi 40.09% <50.00%> (-0.10%) ⬇️
plugins-hono 40.42% <50.00%> (-0.10%) ⬇️
plugins-ioredis 38.39% <50.00%> (-0.10%) ⬇️
plugins-knex 26.57% <ø> (ø)
plugins-langgraph 38.44% <50.00%> (-0.10%) ⬇️
plugins-ldapjs 24.43% <ø> (ø)
plugins-light-my-request 26.30% <ø> (ø)
plugins-limitd-client 32.48% <50.00%> (-0.10%) ⬇️
plugins-lodash 26.03% <ø> (ø)
plugins-mariadb 39.43% <50.00%> (-0.10%) ⬇️
plugins-memcached 38.13% <50.00%> (-0.10%) ⬇️
plugins-microgateway-core 39.16% <50.00%> (-0.10%) ⬇️
plugins-moleculer 40.45% <50.00%> (-0.09%) ⬇️
plugins-mongodb 39.10% <50.00%> (-0.09%) ⬇️
plugins-mongodb-core 38.94% <50.00%> (-0.10%) ⬇️
plugins-mongoose 38.82% <50.00%> (-0.09%) ⬇️
plugins-multer 26.70% <ø> (ø)
plugins-mysql 39.13% <50.00%> (-0.10%) ⬇️
plugins-mysql2 39.22% <50.00%> (-0.10%) ⬇️
plugins-node-serialize 27.00% <ø> (ø)
plugins-opensearch 37.58% <50.00%> (-0.10%) ⬇️
plugins-passport-http 26.76% <ø> (ø)
plugins-postgres 35.52% <50.00%> (-0.19%) ⬇️
plugins-process 26.73% <ø> (ø)
plugins-pug 26.96% <ø> (ø)
plugins-redis 38.85% <50.00%> (-0.10%) ⬇️
plugins-router 43.02% <50.00%> (-0.24%) ⬇️
plugins-sequelize 25.55% <ø> (ø)
plugins-test-and-upstream-amqp10 38.44% <50.00%> (+0.04%) ⬆️
plugins-test-and-upstream-amqplib 44.14% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-apollo 39.08% <50.00%> (-0.09%) ⬇️
plugins-test-and-upstream-avsc 38.52% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-bunyan 33.79% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-connect 40.74% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-graphql 40.09% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-koa 40.34% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-protobufjs 38.74% <50.00%> (-0.10%) ⬇️
plugins-test-and-upstream-rhea 44.15% <50.00%> (-0.13%) ⬇️
plugins-undici 39.07% <50.00%> (-0.09%) ⬇️
plugins-url 26.73% <ø> (ø)
plugins-valkey 38.10% <50.00%> (-0.10%) ⬇️
plugins-vm 26.73% <ø> (ø)
plugins-winston 33.98% <50.00%> (-0.09%) ⬇️
plugins-ws 41.92% <50.00%> (-0.10%) ⬇️
profiling-macos 40.44% <50.00%> (-0.10%) ⬇️
profiling-ubuntu 40.56% <50.00%> (-0.53%) ⬇️
profiling-windows 42.12% <50.00%> (+0.32%) ⬆️
serverless-azure-functions-client 25.62% <ø> (ø)
serverless-azure-functions-eventhubs 25.62% <ø> (ø)
serverless-azure-functions-servicebus 25.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@datadog-official
Copy link
Copy Markdown

datadog-official Bot commented Mar 4, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 41.51%
Overall Coverage: 69.05% (-5.30%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 41905e7 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@tlhunter tlhunter force-pushed the tlhunter/webpack branch 2 times, most recently from 0715b50 to 33857e5 Compare March 5, 2026 18:02
Comment thread packages/datadog-webpack/index.js Outdated
@tlhunter tlhunter force-pushed the tlhunter/webpack branch 2 times, most recently from 5333d4d to a76a9a2 Compare March 9, 2026 21:49
@tlhunter tlhunter changed the title feat(bundler): add webpack 5 plugin for dd-trace bundling feat(bundler): experimental webpack bundling support Mar 9, 2026
@tlhunter tlhunter marked this pull request as ready for review March 9, 2026 22:03
@tlhunter tlhunter requested review from a team as code owners March 9, 2026 22:03
Comment thread .github/CODEOWNERS Outdated
@tlhunter
Copy link
Copy Markdown
Member Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 58cbf51855

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-webpack/index.js Outdated
Comment thread packages/datadog-webpack/index.js Outdated
@tlhunter
Copy link
Copy Markdown
Member Author

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8bf9e1ab24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/datadog-webpack/index.js
Comment thread package.json
Comment on lines 37 to +40
"test:esbuild": "mocha packages/datadog-esbuild/test/**/*.spec.js",
"test:esbuild:ci": "nyc -- npm run test:esbuild",
"test:webpack": "mocha packages/datadog-webpack/test/**/*.spec.js",
"test:webpack:ci": "nyc -- npm run test:webpack",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have one script for all bundlers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that approach but it was pretty messy. There's a tool called unplugin we can use but I wasn't able to get the code any cleaner.

#7645

Comment thread webpack.js
Comment thread packages/datadog-webpack/index.js
@IlyasShabi
Copy link
Copy Markdown
Contributor

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db23a6fc1f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

throw e
}

if (isESMFile(normalizedResource, pkgJson, packageJson)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve native separators for ESM detection

normalizedResource (forward-slash path) is passed into isESMFile, but that helper splits on path.sep. On Windows this means the path never splits as intended, so ESM detection falls back to unrelated package.json lookups (often the app root) and can misclassify ESM files as CJS. In webpack bundles on Windows, this can cause the loader to be injected into ESM modules and break instrumentation/runtime behavior. Use the original platform path for isESMFile (or normalize inside that helper consistently).

Useful? React with 👍 / 👎.

@IlyasShabi
Copy link
Copy Markdown
Contributor

@CarlesDD IIRC we had an issue with IAST and esbuild that was fixed by Ugaitz, could you please check if IAST will continue to work with webpack plugin please

@tlhunter
Copy link
Copy Markdown
Member Author

I'm fine with sussing out if the IAST issue still exists after this gets merged. It's marked as experimental after all.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@IlyasShabi IlyasShabi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tlhunter tlhunter merged commit 64890d7 into master Mar 26, 2026
1327 of 1335 checks passed
@tlhunter tlhunter deleted the tlhunter/webpack branch March 26, 2026 16:13
dd-octo-sts Bot pushed a commit that referenced this pull request Mar 27, 2026
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@dd-octo-sts dd-octo-sts Bot mentioned this pull request Mar 27, 2026
litianningdatadog pushed a commit that referenced this pull request Mar 30, 2026
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
juan-fernandez pushed a commit that referenced this pull request Apr 1, 2026
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI Generated Largely based on code generated by an AI or LLM. This label is the same across all dd-trace-* repos bundler semver-minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants