fix(compile): resolve bare npm imports in --bundle worker sources#34967
Merged
Conversation
deno compile --bundle follows new Worker(new URL(...)) references and pulls the referenced source modules into the graph. When the entrypoint lives in a subdirectory with its own package scope (e.g. a dist/ build output) and the worker is authored in a sibling source tree, a bare npm import from that worker source fails to resolve even though the package is installed and resolves fine elsewhere in the same build, surfacing as "Import X not a dependency". Fall back to resolving such bare specifiers against the build's npm snapshot by package name, matching Node/Bun behavior. Closes #34937
bartlomieju
commented
Jun 6, 2026
bartlomieju
left a comment
Member
Author
There was a problem hiding this comment.
Nicely scoped fix — loosening only after strict graph resolution has already failed is the right shape, and the doc comments + PR description are great. A few things worth addressing before merge, left inline. Main one is version selection when the snapshot holds more than one version of a package; the rest are nits / a test-fidelity check.
…, tighten worker test fixture
bartlomieju
enabled auto-merge (squash)
June 6, 2026 12:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deno compile --bundle follows new Worker(new URL(...)) references and
pulls the referenced modules into the bundle graph. When the entrypoint
lives in a subdirectory with its own package scope (for example a dist/
build output with its own package.json) and a worker is authored in a
sibling source tree, a bare npm import from that worker source failed
to resolve with "Import X not a dependency", even though the package is
declared, installed, and resolves fine from the entrypoint's own tree
in the same build. Plain deno bundle was unaffected because it does not
follow those worker references into the source tree.
The package is already present in the build's resolved npm snapshot, so
this falls back to resolving such bare specifiers against that snapshot
by package name, the way Node and Bun locate a package in a reachable
node_modules. The fallback only runs after normal resolution has already
failed, so successful resolutions and plain deno bundle behavior are
unchanged.
Closes #34937