Repository navigation
fix(mcp): resolve named engines using export conditions - #1762
BloggerBust wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
No issues found across 9 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Thanks for the issue, the repro and the fix! #1759 also fixes #1758, so both PRs get the same comparison.
I tested it with a fake engine package in 22 export shapes and compared the file each resolver picks with the file a real import() loads (Node 24). The main problem is the rule. default-engine.ts:~31 resolves with node, import and require all on, so the package's own key order decides. import() never matches require, which means this only fixes packages that list import first (the issue's repro). These all still load the require file:
{require, import}{".": {types, require, import}}- nested
node: {require, import} {require, default}- require-first subpath and pattern exports, and pnpm-linked require-first packages
The tests lock in that behavior: "loads dual ... require" expects cjs, and the nested tests compare against import() run with --conditions=require.
Asks:
- Resolve with import conditions only (
['node', 'import', 'module-sync']), and fall back to main'screateRequire().resolveonERR_PACKAGE_PATH_NOT_EXPORTEDfor CommonJS-only engines. With that one change,resolveModuleURLmatchedimport()in all 22 cases. - Remove
addonsEnabled/nodeOptionsArgs, the hand-writtenNODE_OPTIONSparser that only decidesnode-addons, along with the ~20 child-process tests that cover it. - Flip the require-first tests to expect
esm. - 5/51 tests fail on macOS because
/varand/private/vardiffer. Comparerealpaths in the error-path tests. - Remove the additions to
docs/reference/mcp.mdx:589-593and bothskills/.../mcp.mdcopies.--conditionsand loader hooks are internals. - Reword the changeset: "first matching entry in export order" describes the wrong rule. Something like: "MCP sessions load an engine package's
importentry, asimport()does." nodeEngineConditionsneeds JSDoc.
Whether e2e takes exsolve (1.2.0, no dependencies of its own, 59 KB) as a runtime dependency is a maintainer call, and so is which of the two PRs carries the fix.
Resolve named MCP engine packages using ESM import conditions to match how the modules are loaded.
34886e6 to
b55cba1
Compare
|
@okwasniewski Thanks for the review. I have updated the PR to use ESM import conditions, removed the Also, the |
|
Hey @okwasniewski, there are some challenges implementing the Here is the behavior I am proposing:
The idea is to keep In the meantime, I will investigate a few more resolver candidates to see whether there is a better solution. |
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Thanks, all previous asks are in. I compared 36 export shapes against a real
Approved CI for this head. |
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 3 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.
View guided diff | Re-trigger cubic
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Re-reviewed at
Optional nits:
Nothing blocking on the code. The only open item is a maintainer call on adding |
All asks done at 5b46679, see latest comment (automated review).
# Conflicts: # packages/e2e/src/mcp/default-engine.ts
|
Note Automated review. Main moved the engine imports to |
What and why
exsolvewith ESM import conditions, matching how the modules are loaded.Issue
Fixes #1758
Verified
Ran it locally: yes
e2e@0.23.1: the standalone reproduction confirms the wrong export is selected.Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.