Skip to content

fix(worker-bundler): resolve package subpaths without an exports map - #2471

Merged
mattzcarey merged 2 commits into
cloudflare:mainfrom
mattzcarey:fix/issue-2466
Oct 4, 2026
Merged

mattzcarey merged 2 commits into
cloudflare:mainfrom
mattzcarey:fix/issue-2466

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

Fixes #2466

  • resolvePackage() tried the legacy main/module entry before the requested subpath, so fixture/internal resolved to fixture/index.js. This breaks packages like ajv-formats that import ajv/dist/compile/codegen.
  • The legacy fallback now applies only to root imports. For packages without an exports map, subpaths fall through to extension/index resolution.
  • A package that has an exports map keeps that boundary: a subpath it does not export stays unresolved instead of being read from disk.
-if (legacyEntry && typeof legacyEntry === "string") {
+if (!subpath && legacyEntry && typeof legacyEntry === "string") {
 ...
+if (subpath && pkg.exports !== undefined) {
+  return { path: specifier, external: true };
+}

Tests cover root, directory, file and scoped subpaths in transform-only and bundled mode, plus a subpath excluded by exports.

@changeset-bot

changeset-bot Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ad2ecf4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cloudflare/worker-bundler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

@agent-think

agent-think Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (2f3176b9 → ad2ecf44, workflow run)

@pkg-pr-new

pkg-pr-new Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2471

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2471

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2471

hono-agents

npm i https://pkg.pr.new/hono-agents@2471

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2471

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2471

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2471

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2471

commit: ad2ecf4

@mattzcarey
mattzcarey merged commit 26798f1 into cloudflare:main Oct 4, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 4, 2026
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.

worker-bundler: package subpaths resolve to the root entrypoint without an exports map

1 participant