summaryrefslogtreecommitdiff
path: root/cli/resolver.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-08-24 19:36:05 +0200
committerGitHub <noreply@github.com>2022-08-24 19:36:05 +0200
commit33c4d45328166d103e99a8c243727eead626080c (patch)
tree70331a9964f8faf780942696c34aab867accf7bf /cli/resolver.rs
parent6bb72a80863ac3913d32ea21aae32dd327ce6b71 (diff)
fix: resolve `jsxImportSource` relative to module (#15561)
Previously `jsxImportSource` was resolved relative to the config file during graph building, and relative to the emitted module during runtime. This is now fixed so that the JSX import source is resolved relative to the module both during graph building and at runtime.
Diffstat (limited to 'cli/resolver.rs')
-rw-r--r--cli/resolver.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/cli/resolver.rs b/cli/resolver.rs
index 30149278c..2e97cfe1f 100644
--- a/cli/resolver.rs
+++ b/cli/resolver.rs
@@ -7,6 +7,8 @@ use deno_graph::source::Resolver;
use import_map::ImportMap;
use std::sync::Arc;
+use crate::args::config_file::JsxImportSourceConfig;
+
/// Wraps an import map to be used when building a deno_graph module graph.
/// This is done to avoid having `import_map` be a direct dependency of
/// `deno_graph`.
@@ -38,17 +40,19 @@ impl Resolver for ImportMapResolver {
#[derive(Debug, Default, Clone)]
pub struct JsxResolver {
+ default_jsx_import_source: Option<String>,
jsx_import_source_module: String,
maybe_import_map_resolver: Option<ImportMapResolver>,
}
impl JsxResolver {
pub fn new(
- jsx_import_source_module: String,
+ jsx_import_source_config: JsxImportSourceConfig,
maybe_import_map_resolver: Option<ImportMapResolver>,
) -> Self {
Self {
- jsx_import_source_module,
+ default_jsx_import_source: jsx_import_source_config.default_specifier,
+ jsx_import_source_module: jsx_import_source_config.module,
maybe_import_map_resolver,
}
}
@@ -59,6 +63,10 @@ impl JsxResolver {
}
impl Resolver for JsxResolver {
+ fn default_jsx_import_source(&self) -> Option<String> {
+ self.default_jsx_import_source.clone()
+ }
+
fn jsx_import_source_module(&self) -> &str {
self.jsx_import_source_module.as_str()
}