[NOJIRA][FIX][V2] Skip Babel and Metro plugins for web platform builds#1278
Merged
cdn34dd merged 1 commit intofeature/v2from Apr 28, 2026
Merged
Conversation
- Babel plugin: skip all transforms when caller platform is 'web' - Metro serializer (withDatadogMetroConfig): skip debug ID injection for web - Metro serializer (Expo plugin): skip debug ID injection for web
sbarrio
approved these changes
Apr 28, 2026
There was a problem hiding this comment.
Pull request overview
Adds platform awareness to Datadog’s React Native build tooling so that web bundles do not receive native-only Babel/Metro instrumentation artifacts.
Changes:
- Skip Datadog Babel plugin transforms when
caller.platform === 'web'. - Skip Metro Debug ID injection for
graph.transformOptions.platform === 'web'(serializer + Expounstable_beforeAssetSerializationPluginpath). - Add/extend unit tests to validate web skipping behavior (serializer + babel plugin).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/react-native-babel-plugin/src/index.ts | Adds a web platform guard intended to bypass plugin transforms. |
| packages/react-native-babel-plugin/test/plugin.test.ts | Adds a test asserting no Datadog artifacts are injected for web builds. |
| packages/core/src/metro/plugin/metroSerializer.ts | Adds web platform guards for serializer Debug ID injection and the Expo pre-asset plugin path. |
| packages/core/src/metro/tests/metro.test.ts | Adds a test asserting serializer skips Debug ID injection on web. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
For cross-platform React Native apps that also target web (e.g., Expo with web support), the Babel plugin and Metro serializer were running unconditionally on all platforms, injecting native-only code into web bundles.
This PR adds awareness for the web platform so that web builds are skipped:
@datadog/mobile-react-native-babel-plugin: Skips all transforms when it's 'web'. This prevents injection ofDdBabelInteractionTrackingwrappers,__ddExtractTexthelpers, and the__DD_RN_BABEL_PLUGIN_ENABLED__flag into web bundles.createDatadogMetroSerializer(used by withDatadogMetroConfig): Skips debug ID injection for web builds.unstable_beforeAssetSerializationPlugin(used by getDatadogExpoConfig): Same platform check for the Expo-specific code path.When checking on a resulting bundle for an expo app built for the web, all Datadog artifacts created by babel & expo were eliminated.
DdBabelInteractionTracking__ddExtractText_datadogDebugIdsdatadog-debug-idMotivation
Issue #1204
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)