Skip to content

💥 use ESM dynamic imports for CDN async chunks#4217

Merged
BenoitZugmeyer merged 3 commits intov7from
benoit/esm-cdn-chunks
Feb 20, 2026
Merged

💥 use ESM dynamic imports for CDN async chunks#4217
BenoitZugmeyer merged 3 commits intov7from
benoit/esm-cdn-chunks

Conversation

@BenoitZugmeyer
Copy link
Copy Markdown
Member

@BenoitZugmeyer BenoitZugmeyer commented Feb 19, 2026

Motivation

CDN async chunks (recorder, profiler) were previously loaded via JSONP (script tag injection). Switching to native ESM dynamic imports aligns chunk loading with modern browser capabilities and removes the need for a global chunk registry.

ESM dynamic imports require the main script tag to have a crossorigin attribute, and the developer extension's inline script injection needed to be updated to rewrite relative chunk import paths to absolute URLs.

Changes

  • webpack.base.ts: set chunkFormat: 'module' and chunkLoading: 'import' to emit async chunks as ES modules loaded via import(). The main entry bundle format is unchanged.
  • All <script> tags and createElement('script') calls loading the SDK bundle now include a crossorigin attribute (test apps, E2E framework, performance tests, sandbox).
  • developer-extension: the dev bundle injection rewrites relative import('./...') paths to absolute URLs, since the script is injected inline rather than loaded via <script src\>.

Test instructions

Build the SDK (yarn build) and verify the generated files in bundle/chunks/ are valid ES modules.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented Feb 19, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 76.94% (+0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 26f952a | Docs | Datadog PR Page | Was this helpful? Give us feedback!

@cit-pr-commenter-54b7da
Copy link
Copy Markdown

cit-pr-commenter-54b7da Bot commented Feb 20, 2026

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 172.00 KiB 170.35 KiB -1.64 KiB -0.96%
Rum Profiler 4.67 KiB 4.69 KiB +23 B +0.48%
Rum Recorder 24.88 KiB 24.91 KiB +23 B +0.09%
Logs 56.38 KiB 56.38 KiB 0 B 0.00%
Flagging 944 B 944 B 0 B 0.00%
Rum Slim 127.63 KiB 127.63 KiB 0 B 0.00%
Worker 23.63 KiB 23.63 KiB 0 B 0.00%
🚀 CPU Performance
Action Name Base CPU Time (ms) Local CPU Time (ms) 𝚫%
RUM - add global context 0.0039 0.0056 +43.59%
RUM - add action 0.0126 0.0192 +52.38%
RUM - add error 0.0125 0.0178 +42.40%
RUM - add timing 0.0025 0.0037 +48.00%
RUM - start view 0.0122 0.0178 +45.90%
RUM - start/stop session replay recording 0.0006 0.0011 +83.33%
Logs - log message 0.0139 0.0227 +63.31%
🧠 Memory Performance
Action Name Base Memory Consumption Local Memory Consumption 𝚫
RUM - add global context 27.21 KiB 27.53 KiB +326 B
RUM - add action 112.50 KiB 113.67 KiB +1.18 KiB
RUM - add timing 26.47 KiB 26.06 KiB -419 B
RUM - add error 117.98 KiB 119.57 KiB +1.59 KiB
RUM - start/stop session replay recording 25.43 KiB 26.27 KiB +860 B
RUM - start view 505.98 KiB 499.36 KiB -6.62 KiB
Logs - log message 44.79 KiB 46.05 KiB +1.26 KiB

🔗 RealWorld

@BenoitZugmeyer BenoitZugmeyer changed the title 👷 use ESM dynamic imports for CDN async chunks 💥 use ESM dynamic imports for CDN async chunks Feb 20, 2026
@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review February 20, 2026 11:15
@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner February 20, 2026 11:15
@BenoitZugmeyer
Copy link
Copy Markdown
Member Author

/to-staging

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented Feb 20, 2026

View all feedbacks in Devflow UI.

2026-02-20 11:15:50 UTC ℹ️ Start processing command /to-staging


2026-02-20 11:15:56 UTC ℹ️ Branch Integration: starting soon, merge expected in approximately 24m (p90)

Commit 26f952a1f2 will soon be integrated into staging-08.


2026-02-20 11:32:14 UTC ℹ️ Branch Integration: this commit was successfully integrated

Commit 26f952a1f2 has been merged into staging-08 in merge commit 4e179f9a3b.

Check out the triggered DDCI request.

If you need to revert this integration, you can use the following command: /code revert-integration -b staging-08

gh-worker-dd-mergequeue-cf854d Bot added a commit that referenced this pull request Feb 20, 2026
Integrated commit sha: 26f952a

Co-authored-by: BenoitZugmeyer <benoit.zugmeyer@datadoghq.com>
@BenoitZugmeyer BenoitZugmeyer merged commit 35bfecf into v7 Feb 20, 2026
20 checks passed
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/esm-cdn-chunks branch February 20, 2026 13:40
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants