Skip to content

feat(server-utils): Warn when bundler config has instrumented module in external#22379

Merged
timfish merged 2 commits into
developfrom
timfish/feat/orchestrion-bunlers
Jul 20, 2026
Merged

feat(server-utils): Warn when bundler config has instrumented module in external#22379
timfish merged 2 commits into
developfrom
timfish/feat/orchestrion-bunlers

Conversation

@timfish

@timfish timfish commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

If users have a library we instrument in their bundler external config we should warn them about the fact that this stops it from getting instrumented!

@timfish
timfish requested a review from a team as a code owner July 19, 2026 16:25
@timfish
timfish requested review from isaacs, msonnb, mydea and stephanie-anderson and removed request for a team July 19, 2026 16:25
Comment thread packages/server-utils/src/orchestrion/bundler/vite.ts
@andreiborza
andreiborza removed the request for review from stephanie-anderson July 20, 2026 08:58

@isaacs isaacs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code and tests LGTM, but probably worth fixing the doc comment issue (assuming I'm reading that correctly).

* bundler path ran (rather than relying on a build-time flag that wouldn't be
* visible to the runtime).
*/
/**

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like this code got inserted between a doc comment and its target? Shouldn't that bit above be attached to the orchestrionTransformOptions below?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ah nice find!

// its diagnostics_channel calls are silently never injected. By the time
// buildStart runs, Rollup has normalized `external` (string arrays,
// RegExps or user functions) into a single predicate we can probe.
const externalizedModules = moduleNames.filter(name => rollupOptions.external(name, undefined, false));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice, I didn't realize it did that. Very convenient.

@timfish
timfish enabled auto-merge (squash) July 20, 2026 22:36

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 3 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b496d7c. Configure here.

);
if (externalizedModules.length > 0) {
build.onStart(() => ({ warnings: [{ text: externalizedModulesWarning(externalizedModules) }] }));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Esbuild misses packages external option

Medium Severity

The new esbuild warning only inspects initialOptions.external, so the common Node setup packages: 'external' never warns even though it externalizes every instrumented package. The Bun orchestrion plugin already treats that blanket mode as a warning case, so esbuild users hit the silent failure this PR aims to catch.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b496d7c. Configure here.

if (entry.includes('*')) {
return new RegExp(`^${entry.split('*').map(escapeStringForRegex).join('.*')}$`).test(moduleName);
}
return externalEntryMatchesModule(entry, moduleName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wildcard subpaths skip esbuild warning

Low Severity

When an esbuild external entry contains *, matching only regex-tests the bare package name. Patterns like mysql/* therefore never warn, even though the non-wildcard path correctly treats subpath externals such as mysql/lib/... as covering the instrumented package.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b496d7c. Configure here.

expect(runConfigResolved(['lodash'])).not.toHaveBeenCalled();
expect(runConfigResolved(undefined)).not.toHaveBeenCalled();
});
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Feat PR lacks integration tests

Low Severity

This is a feat PR and only adds mocked unit tests for the new externalization warnings. Per the PR review guidelines, feat changes need at least one integration or E2E test; none were added for this behavior across the bundler plugins.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit b496d7c. Configure here.

@timfish
timfish merged commit 83659e1 into develop Jul 20, 2026
312 of 313 checks passed
@timfish
timfish deleted the timfish/feat/orchestrion-bunlers branch July 20, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants