mirror of
https://github.com/denoland/deno.git
synced 2025-07-24 13:44:08 +00:00
fix: support bun specifiers in JSR publish (#24588)
Fixes https://github.com/denoland/deno/issues/26989 --------- Co-authored-by: Nathan Whitaker <nathan@deno.com>
This commit is contained in:
parent
52bcd35d9d
commit
4a0bbd0a71
11 changed files with 62 additions and 18 deletions
|
@ -6,6 +6,7 @@ use crate::args::CliLockfile;
|
|||
use crate::args::CliOptions;
|
||||
use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS;
|
||||
use crate::cache;
|
||||
use crate::cache::FetchCacher;
|
||||
use crate::cache::GlobalHttpCache;
|
||||
use crate::cache::ModuleInfoCache;
|
||||
use crate::cache::ParsedSourceCache;
|
||||
|
@ -254,6 +255,23 @@ impl ModuleGraphCreator {
|
|||
package_configs: &[JsrPackageConfig],
|
||||
build_fast_check_graph: bool,
|
||||
) -> Result<ModuleGraph, AnyError> {
|
||||
struct PublishLoader(FetchCacher);
|
||||
impl Loader for PublishLoader {
|
||||
fn load(
|
||||
&self,
|
||||
specifier: &deno_ast::ModuleSpecifier,
|
||||
options: deno_graph::source::LoadOptions,
|
||||
) -> deno_graph::source::LoadFuture {
|
||||
if specifier.scheme() == "bun" {
|
||||
return Box::pin(std::future::ready(Ok(Some(
|
||||
deno_graph::source::LoadResponse::External {
|
||||
specifier: specifier.clone(),
|
||||
},
|
||||
))));
|
||||
}
|
||||
self.0.load(specifier, options)
|
||||
}
|
||||
}
|
||||
fn graph_has_external_remote(graph: &ModuleGraph) -> bool {
|
||||
// Earlier on, we marked external non-JSR modules as external.
|
||||
// If the graph contains any of those, it would cause type checking
|
||||
|
@ -271,12 +289,15 @@ impl ModuleGraphCreator {
|
|||
for package_config in package_configs {
|
||||
roots.extend(package_config.config_file.resolve_export_value_urls()?);
|
||||
}
|
||||
|
||||
let loader = self.module_graph_builder.create_graph_loader();
|
||||
let mut publish_loader = PublishLoader(loader);
|
||||
let mut graph = self
|
||||
.create_graph_with_options(CreateGraphOptions {
|
||||
is_dynamic: false,
|
||||
graph_kind: deno_graph::GraphKind::All,
|
||||
roots,
|
||||
loader: None,
|
||||
loader: Some(&mut publish_loader),
|
||||
})
|
||||
.await?;
|
||||
self.graph_valid(&graph)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue