docs: loader hooks don't resolve jsr:/npm:/https: specifiers#3405
Merged
Conversation
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.
The Loader hooks reference didn't mention that external specifiers introduced
by hook-emitted source aren't resolved automatically. This trips people up when
they use a
loadhook to transpile a custom format (e.g. Civet, CoffeeScript)whose output imports an npm or jsr package.
The reason is that Deno discovers and installs dependencies by statically
analyzing the module graph before execution, whereas hook-generated source is
produced at load time, after that analysis has finished. A bare
jsr:,npm:,or
https:import that only appears in the emitted source is therefore invisibleto dependency resolution and fails with an error like
Could not find constraint 'lodash-es@latest' in the list of packages.This adds an info box to the Custom transpilation use case documenting the
limitation, explaining why it happens, and showing the workaround of declaring
the dependency in
deno.jsonup front. This is working as designed, so the docsshould set the expectation.
Refs denoland/deno#35896