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.
This commit is contained in:
Luca Casonato 2022-08-24 19:36:05 +02:00 committed by GitHub
parent 6bb72a8086
commit 33c4d45328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 79 additions and 42 deletions

View file

@ -34,6 +34,7 @@ use std::env;
use std::net::SocketAddr;
use std::path::PathBuf;
use crate::args::config_file::JsxImportSourceConfig;
use crate::compat;
use crate::deno_dir::DenoDir;
use crate::emit::get_ts_config_for_emit;
@ -210,12 +211,14 @@ impl CliOptions {
}
}
/// Return the implied JSX import source module.
pub fn to_maybe_jsx_import_source_module(&self) -> Option<String> {
/// Return the JSX import source configuration.
pub fn to_maybe_jsx_import_source_config(
&self,
) -> Option<JsxImportSourceConfig> {
self
.maybe_config_file
.as_ref()
.and_then(|c| c.to_maybe_jsx_import_source_module())
.and_then(|c| c.to_maybe_jsx_import_source_config())
}
/// Return any imports that should be brought into the scope of the module