fix(repl): jsxImportSource was not working (#21049)

I made some fixes in deno_ast to make this possible and we forgot to
update this.
This commit is contained in:
David Sherret 2023-11-01 19:04:54 -04:00 committed by GitHub
parent ab72019a17
commit 58d543a480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 29 additions and 10 deletions

4
Cargo.lock generated
View file

@ -1213,9 +1213,9 @@ dependencies = [
[[package]]
name = "deno_doc"
version = "0.72.1"
version = "0.72.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bea5dacf0b7739d8e829e7c1ccd236929d9ff9a9fd63fb8aefb0c0b5e64fa86"
checksum = "48c00aff446bb7a0b9ef34418420650ee803e41251c034b9a944538dc80f1b65"
dependencies = [
"anyhow",
"cfg-if",

View file

@ -49,7 +49,7 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra
deno_cache_dir = "=0.6.1"
deno_config = "=0.5.0"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "=0.72.1", features = ["html"] }
deno_doc = { version = "=0.72.2", features = ["html"] }
deno_emit = "=0.31.1"
deno_graph = "=0.59.2"
deno_lint = { version = "=0.52.2", features = ["docs"] }

View file

@ -417,7 +417,7 @@ pub struct Flags {
pub reload: bool,
pub seed: Option<u64>,
pub unstable: bool,
pub unstable_bare_node_builtlins: bool,
pub unstable_bare_node_builtins: bool,
pub unstable_byonm: bool,
pub unstable_features: Vec<String>,
pub unsafely_ignore_certificate_errors: Option<Vec<String>>,
@ -856,7 +856,7 @@ pub fn flags_from_vec(args: Vec<String>) -> clap::error::Result<Flags> {
.push(deno_runtime::deno_cron::UNSTABLE_FEATURE_NAME.to_string());
}
flags.unstable_bare_node_builtlins =
flags.unstable_bare_node_builtins =
matches.get_flag("unstable-bare-node-builtins");
flags.unstable_byonm = matches.get_flag("unstable-byonm");

View file

@ -1249,8 +1249,8 @@ impl CliOptions {
self.flags.unstable
}
pub fn unstable_bare_node_builtlins(&self) -> bool {
self.flags.unstable_bare_node_builtlins
pub fn unstable_bare_node_builtins(&self) -> bool {
self.flags.unstable_bare_node_builtins
|| self
.maybe_config_file()
.as_ref()

View file

@ -392,7 +392,7 @@ impl CliFactory {
maybe_vendor_dir: self.options.vendor_dir_path(),
bare_node_builtins_enabled: self
.options
.unstable_bare_node_builtlins(),
.unstable_bare_node_builtins(),
})))
})
.await

View file

@ -504,6 +504,23 @@ fn jsx_errors_without_pragma() {
});
}
#[test]
fn jsx_import_source() {
let context = TestContextBuilder::default()
.use_temp_cwd()
.use_http_server()
.build();
context
.new_command()
.args_vec(["repl", "-A"])
.with_pty(|mut console| {
console.write_line("/** @jsxImportSource http://localhost:4545/jsx */");
console.expect("undefined");
console.write_line("const element = <div />;");
console.expect("undefined");
});
}
#[test]
fn type_error() {
util::with_pty(&["repl"], |mut console| {

View file

@ -590,11 +590,11 @@ impl ReplSession {
imports_not_used_as_values: ImportsNotUsedAsValues::Preserve,
transform_jsx: true,
precompile_jsx: false,
jsx_automatic: false,
jsx_automatic: self.jsx.import_source.is_some(),
jsx_development: false,
jsx_factory: self.jsx.factory.clone(),
jsx_fragment_factory: self.jsx.frag_factory.clone(),
jsx_import_source: None,
jsx_import_source: self.jsx.import_source.clone(),
var_decl_imports: true,
})?
.text;
@ -620,9 +620,11 @@ impl ReplSession {
if let Some(jsx) = analyzed_pragmas.jsx {
self.jsx.factory = jsx.text;
self.jsx.import_source = None;
}
if let Some(jsx_frag) = analyzed_pragmas.jsx_fragment {
self.jsx.frag_factory = jsx_frag.text;
self.jsx.import_source = None;
}
if let Some(jsx_import_source) = analyzed_pragmas.jsx_import_source {
self.jsx.import_source = Some(jsx_import_source.text);