mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -05:00
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:
parent
ab72019a17
commit
58d543a480
7 changed files with 29 additions and 10 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -1213,9 +1213,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deno_doc"
|
name = "deno_doc"
|
||||||
version = "0.72.1"
|
version = "0.72.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6bea5dacf0b7739d8e829e7c1ccd236929d9ff9a9fd63fb8aefb0c0b5e64fa86"
|
checksum = "48c00aff446bb7a0b9ef34418420650ee803e41251c034b9a944538dc80f1b65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
|
|
|
@ -49,7 +49,7 @@ deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "dep_gra
|
||||||
deno_cache_dir = "=0.6.1"
|
deno_cache_dir = "=0.6.1"
|
||||||
deno_config = "=0.5.0"
|
deno_config = "=0.5.0"
|
||||||
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
|
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_emit = "=0.31.1"
|
||||||
deno_graph = "=0.59.2"
|
deno_graph = "=0.59.2"
|
||||||
deno_lint = { version = "=0.52.2", features = ["docs"] }
|
deno_lint = { version = "=0.52.2", features = ["docs"] }
|
||||||
|
|
|
@ -417,7 +417,7 @@ pub struct Flags {
|
||||||
pub reload: bool,
|
pub reload: bool,
|
||||||
pub seed: Option<u64>,
|
pub seed: Option<u64>,
|
||||||
pub unstable: bool,
|
pub unstable: bool,
|
||||||
pub unstable_bare_node_builtlins: bool,
|
pub unstable_bare_node_builtins: bool,
|
||||||
pub unstable_byonm: bool,
|
pub unstable_byonm: bool,
|
||||||
pub unstable_features: Vec<String>,
|
pub unstable_features: Vec<String>,
|
||||||
pub unsafely_ignore_certificate_errors: Option<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());
|
.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");
|
matches.get_flag("unstable-bare-node-builtins");
|
||||||
flags.unstable_byonm = matches.get_flag("unstable-byonm");
|
flags.unstable_byonm = matches.get_flag("unstable-byonm");
|
||||||
|
|
||||||
|
|
|
@ -1249,8 +1249,8 @@ impl CliOptions {
|
||||||
self.flags.unstable
|
self.flags.unstable
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn unstable_bare_node_builtlins(&self) -> bool {
|
pub fn unstable_bare_node_builtins(&self) -> bool {
|
||||||
self.flags.unstable_bare_node_builtlins
|
self.flags.unstable_bare_node_builtins
|
||||||
|| self
|
|| self
|
||||||
.maybe_config_file()
|
.maybe_config_file()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
|
@ -392,7 +392,7 @@ impl CliFactory {
|
||||||
maybe_vendor_dir: self.options.vendor_dir_path(),
|
maybe_vendor_dir: self.options.vendor_dir_path(),
|
||||||
bare_node_builtins_enabled: self
|
bare_node_builtins_enabled: self
|
||||||
.options
|
.options
|
||||||
.unstable_bare_node_builtlins(),
|
.unstable_bare_node_builtins(),
|
||||||
})))
|
})))
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
|
|
@ -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]
|
#[test]
|
||||||
fn type_error() {
|
fn type_error() {
|
||||||
util::with_pty(&["repl"], |mut console| {
|
util::with_pty(&["repl"], |mut console| {
|
||||||
|
|
|
@ -590,11 +590,11 @@ impl ReplSession {
|
||||||
imports_not_used_as_values: ImportsNotUsedAsValues::Preserve,
|
imports_not_used_as_values: ImportsNotUsedAsValues::Preserve,
|
||||||
transform_jsx: true,
|
transform_jsx: true,
|
||||||
precompile_jsx: false,
|
precompile_jsx: false,
|
||||||
jsx_automatic: false,
|
jsx_automatic: self.jsx.import_source.is_some(),
|
||||||
jsx_development: false,
|
jsx_development: false,
|
||||||
jsx_factory: self.jsx.factory.clone(),
|
jsx_factory: self.jsx.factory.clone(),
|
||||||
jsx_fragment_factory: self.jsx.frag_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,
|
var_decl_imports: true,
|
||||||
})?
|
})?
|
||||||
.text;
|
.text;
|
||||||
|
@ -620,9 +620,11 @@ impl ReplSession {
|
||||||
|
|
||||||
if let Some(jsx) = analyzed_pragmas.jsx {
|
if let Some(jsx) = analyzed_pragmas.jsx {
|
||||||
self.jsx.factory = jsx.text;
|
self.jsx.factory = jsx.text;
|
||||||
|
self.jsx.import_source = None;
|
||||||
}
|
}
|
||||||
if let Some(jsx_frag) = analyzed_pragmas.jsx_fragment {
|
if let Some(jsx_frag) = analyzed_pragmas.jsx_fragment {
|
||||||
self.jsx.frag_factory = jsx_frag.text;
|
self.jsx.frag_factory = jsx_frag.text;
|
||||||
|
self.jsx.import_source = None;
|
||||||
}
|
}
|
||||||
if let Some(jsx_import_source) = analyzed_pragmas.jsx_import_source {
|
if let Some(jsx_import_source) = analyzed_pragmas.jsx_import_source {
|
||||||
self.jsx.import_source = Some(jsx_import_source.text);
|
self.jsx.import_source = Some(jsx_import_source.text);
|
||||||
|
|
Loading…
Reference in a new issue