fix(mcp): load the import entry of an engine with separate import and require exports
BA
2d ago+164+164+012345678901234567890123456789-15-15-01234567890123456789
What and why
resolveEntryinpackages/e2e/src/mcp/default-engine.tsfound the entry withcreateRequire().resolve(), so it used therequireconditions. It only read theimportentry when that threwERR_PACKAGE_PATH_NOT_EXPORTED. The entry is then loaded withimport(), so a package that exports both picked therequirefile.- Now it reads the
importtarget fromexportsfirst (the existingimportEntryhelper:import,node, ordefault, in the order written).requireresolution stays for packages whoseexportsgive no import target, or that have noexports. - An
importtarget that is missing on disk is reported as "installed ... but its entry cannot be resolved", like the other unloadable entries, instead of falling back to therequirefile. - Patch changeset for
e2e. No docs change: the docs do not describe how the entry is picked.
Issue
Fixes #1758
Verified
Ran it locally: yes
- New unit test in
mcp-default-engine.test.ts: a package with{ import: './index.js', require: './index.cjs' }on.and on a subpath (writtenrequirefirst), each file returning an engine with a different name.
| main | this branch |
|---|---|
from-require (test fails) | from-import for dual and dual/web |
vitest run tests/unit: 3654 pass, 1 skipped.pnpm checkgreen.
Checklist
- Changeset added (
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only. - Breaking change: title carries
!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md). - Docs updated in the same PR: the
docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it. - Contract change: emitted
.d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures. - Engine contract change (
e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.