Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/core/src/metro/__tests__/metro.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ describe('Datadog Metro Plugin', () => {
expect(code).not.toContain('_datadogDebugIds');
});

test('skips debug ID injection for modulesOnly bundles (lazy/split chunks)', async () => {

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.

Not a blocker, but while the fix itself is correct, the test doesn't seem to actually test the issue that caused the error. From what I got on the issue, the error occurs when metro call the serializer twice, one for the main bundle and another for the lazy chunk. So maybe we could try to have that setup in the test as well.

const serializer = createDatadogMetroSerializer();
const args = mockSerializerArgsForEmptyModule();
(args[3] as any).modulesOnly = true;

const bundle = await serializer(...args);
const { code } = await convertSerializerOutput(bundle);
expect(code).not.toContain('debugId');
expect(code).not.toContain('_datadogDebugIds');
});

test('generates bundle and source map with UUID v5 Debug ID', async () => {
const codeSnippetHash = createHash('md5');
codeSnippetHash.update(DEBUG_ID_CODE_SNIPPET);
Expand Down
5 changes: 3 additions & 2 deletions packages/core/src/metro/plugin/metroSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ export const createDatadogMetroSerializer = (
): DatadogMetroSerializer => {
const serializer = customSerializer || createDefaultMetroSerializer();
return async (entryPoint, preModules, graph, options) => {
// Skip for hot reload mode and web builds
// Skip for hot reload mode, web builds and modulesOnly bundles
if (
(graph.transformOptions as any).hot ||
graph.transformOptions.platform === 'web'
graph.transformOptions.platform === 'web' ||
(options as any).modulesOnly
) {
return serializer(entryPoint, preModules, graph, options);
}
Expand Down