Skip to content

Commit

Permalink
feat(cli): add support for jsxImportSourceTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Apr 17, 2024
1 parent 9acbf90 commit 5c6d924
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 59 deletions.
30 changes: 13 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 49 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ license = "MIT"
repository = "https://github.com/denoland/deno"

[workspace.dependencies]
deno_ast = { version = "=0.36.2", features = ["transpiling"] }
deno_ast = { version = "=0.37.0", features = ["transpiling"] }
deno_core = { version = "0.275.0" }

deno_bench_util = { version = "0.141.0", path = "./bench_util" }
Expand Down Expand Up @@ -96,14 +96,23 @@ cache_control = "=0.2.0"
cbc = { version = "=0.1.2", features = ["alloc"] }
# Note: Do not use the "clock" feature of chrono, as it links us to CoreFoundation on macOS.
# Instead use util::time::utc_now()
chrono = { version = "0.4", default-features = false, features = ["std", "serde"] }
chrono = { version = "0.4", default-features = false, features = [
"std",
"serde",
] }
console_static_text = "=0.8.1"
data-encoding = "2.3.3"
data-url = "=0.3.0"
deno_cache_dir = "=0.7.1"
dlopen2 = "0.6.1"
ecb = "=0.1.2"
elliptic-curve = { version = "0.13.4", features = ["alloc", "arithmetic", "ecdh", "std", "pem"] }
elliptic-curve = { version = "0.13.4", features = [
"alloc",
"arithmetic",
"ecdh",
"std",
"pem",
] }
encoding_rs = "=0.8.33"
faster-hex = "0.9"
fastwebsockets = { version = "0.6", features = ["upgrade", "unstable-split"] }
Expand All @@ -118,8 +127,15 @@ http-body-util = "0.1"
http_v02 = { package = "http", version = "0.2.9" }
httparse = "1.8.0"
hyper = { version = "=1.1.0", features = ["full"] }
hyper-util = { version = "=0.1.2", features = ["tokio", "server", "server-auto"] }
hyper_v014 = { package = "hyper", version = "0.14.26", features = ["runtime", "http1"] }
hyper-util = { version = "=0.1.2", features = [
"tokio",
"server",
"server-auto",
] }
hyper_v014 = { package = "hyper", version = "0.14.26", features = [
"runtime",
"http1",
] }
indexmap = { version = "2", features = ["serde"] }
jsonc-parser = { version = "=0.23.0", features = ["serde"] }
lazy-regex = "3"
Expand All @@ -145,7 +161,14 @@ prost = "0.11"
prost-build = "0.11"
rand = "=0.8.5"
regex = "^1.7.0"
reqwest = { version = "=0.11.20", default-features = false, features = ["rustls-tls", "stream", "gzip", "brotli", "socks", "json"] } # pinned because of https://github.com/seanmonstar/reqwest/pull/1955
reqwest = { version = "=0.11.20", default-features = false, features = [
"rustls-tls",
"stream",
"gzip",
"brotli",
"socks",
"json",
] } # pinned because of https://github.com/seanmonstar/reqwest/pull/1955
ring = "^0.17.0"
rusqlite = { version = "=0.29.0", features = ["unlock_notify", "bundled"] }
rustls = "0.21.8"
Expand Down Expand Up @@ -177,12 +200,19 @@ tower-lsp = { version = "=0.20.0", features = ["proposed"] }
url = { version = "< 2.5.0", features = ["serde", "expose_internals"] }
uuid = { version = "1.3.0", features = ["v4"] }
webpki-roots = "0.25.2"
zeromq = { version = "=0.3.4", default-features = false, features = ["tcp-transport", "tokio-runtime"] }
zeromq = { version = "=0.3.4", default-features = false, features = [
"tcp-transport",
"tokio-runtime",
] }
zstd = "=0.12.4"

# crypto
hkdf = "0.12.3"
rsa = { version = "0.9.3", default-features = false, features = ["std", "pem", "hazmat"] } # hazmat needed for PrehashSigner in ext/node
rsa = { version = "0.9.3", default-features = false, features = [
"std",
"pem",
"hazmat",
] } # hazmat needed for PrehashSigner in ext/node

# webgpu
raw-window-handle = "0.5.0"
Expand All @@ -202,15 +232,19 @@ nix = "=0.26.2"
fwdansi = "=1.1.0"
junction = "=0.2.0"
winapi = "=0.3.9"
windows-sys = { version = "0.48.0", features = ["Win32_Foundation", "Win32_Media", "Win32_Storage_FileSystem"] }
windows-sys = { version = "0.48.0", features = [
"Win32_Foundation",
"Win32_Media",
"Win32_Storage_FileSystem",
] }
winres = "=0.1.12"

# NB: the `bench` and `release` profiles must remain EXACTLY the same.
[profile.release]
codegen-units = 1
incremental = true
lto = true
opt-level = 'z' # Optimize for size
opt-level = 'z' # Optimize for size

# Build release with debug symbols: cargo build --profile=release-with-debug
[profile.release-with-debug]
Expand All @@ -222,7 +256,7 @@ debug = true
codegen-units = 1
incremental = true
lto = true
opt-level = 'z' # Optimize for size
opt-level = 'z' # Optimize for size

# Key generation is too slow on `debug`
[profile.dev.package.num-bigint-dig]
Expand Down Expand Up @@ -370,3 +404,7 @@ opt-level = 3
opt-level = 3
[profile.release.package.base64-simd]
opt-level = 3

[patch.crates-io]
deno_graph = { path = "../deno_graph" }
deno_config = { path = "../deno_config" }
53 changes: 41 additions & 12 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ __runtime_js_sources = ["deno_runtime/__runtime_js_sources"]
__vendored_zlib_ng = ["flate2/zlib-ng-compat", "libz-sys/zlib-ng"]

[build-dependencies]
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting", "only_snapshotted_js_sources"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_runtime = { workspace = true, features = [
"include_js_files_for_snapshotting",
"only_snapshotted_js_sources",
] }
deno_core = { workspace = true, features = [
"include_js_files_for_snapshotting",
] }
lazy-regex.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand All @@ -62,21 +67,36 @@ winapi.workspace = true
winres.workspace = true

[dependencies]
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
deno_ast = { workspace = true, features = [
"bundler",
"cjs",
"codegen",
"proposal",
"react",
"sourcemap",
"transforms",
"typescript",
"view",
"visit",
] }
deno_cache_dir = { workspace = true }
deno_config = "=0.15.0"
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "=0.123.1", features = ["html"] }
deno_emit = "=0.39.0"
deno_graph = { version = "=0.71.5", features = ["tokio_executor"] }
deno_lint = { version = "=0.58.2", features = ["docs"] }
deno_core = { workspace = true, features = [
"include_js_files_for_snapshotting",
] }
deno_doc = { version = "=0.124.0", features = ["html"] }
deno_emit = "=0.39.1"
deno_graph = { version = "=0.72.0", features = ["tokio_executor"] }
deno_lint = { version = "=0.58.3", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm = "=0.17.0"
deno_runtime = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_runtime = { workspace = true, features = [
"include_js_files_for_snapshotting",
] }
deno_semver = "=0.5.4"
deno_task_shell = "=0.16.0"
deno_terminal.workspace = true
eszip = "=0.66.0"
eszip = "=0.67.0"
napi_sym.workspace = true

async-trait.workspace = true
Expand All @@ -98,7 +118,7 @@ dotenvy = "0.15.7"
dprint-plugin-json = "=0.19.2"
dprint-plugin-jupyter = "=0.1.3"
dprint-plugin-markdown = "=0.16.4"
dprint-plugin-typescript = "=0.90.1"
dprint-plugin-typescript = "=0.90.2"
env_logger = "=0.10.0"
fancy-regex = "=0.10.0"
faster-hex.workspace = true
Expand Down Expand Up @@ -156,7 +176,16 @@ zstd.workspace = true
[target.'cfg(windows)'.dependencies]
fwdansi.workspace = true
junction.workspace = true
winapi = { workspace = true, features = ["knownfolders", "mswsock", "objbase", "shlobj", "tlhelp32", "winbase", "winerror", "winsock2"] }
winapi = { workspace = true, features = [
"knownfolders",
"mswsock",
"objbase",
"shlobj",
"tlhelp32",
"winbase",
"winerror",
"winsock2",
] }

[target.'cfg(unix)'.dependencies]
nix.workspace = true
Expand Down
21 changes: 7 additions & 14 deletions cli/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Emitter {
let transpile_and_emit_options_hash = {
let mut hasher = FastInsecureHasher::default();
hasher.write_hashable(&transpile_options);
hasher.write_hashable(emit_options);
hasher.write_hashable(&emit_options);
hasher.finish()
};
Self {
Expand Down Expand Up @@ -100,17 +100,9 @@ impl Emitter {
source.clone(),
media_type,
)?;
let transpiled_source = match parsed_source
.transpile_owned(&self.transpile_options, &self.emit_options)
{
Ok(result) => result?,
Err(parsed_source) => {
// transpile_owned is more efficient and should be preferred
debug_assert!(false, "Transpile owned failed.");
parsed_source
.transpile(&self.transpile_options, &self.emit_options)?
}
};
let transpiled_source = parsed_source
.transpile(&self.transpile_options, &self.emit_options)?
.into_source();
debug_assert!(transpiled_source.source_map.is_none());
self.emit_cache.set_emit_code(
specifier,
Expand All @@ -135,10 +127,11 @@ impl Emitter {
let parsed_source = self
.parsed_source_cache
.remove_or_parse_module(specifier, source_arc, media_type)?;
let mut options = self.emit_options;
let mut options = self.emit_options.clone();
options.source_map = SourceMapOption::None;
let transpiled_source = parsed_source
.transpile_owned_with_fallback(&self.transpile_options, &options)?;
.transpile(&self.transpile_options, &options)?
.into_source();
Ok(transpiled_source.text)
}

Expand Down
10 changes: 8 additions & 2 deletions cli/lsp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,8 +1126,14 @@ impl LspTsConfig {
let import_map = import_map?;
let referrer = &config_file?.specifier;
let compiler_options = ts_config.inner.0.as_object_mut()?;
let jsx_import_source =
compiler_options.get("jsxImportSource")?.as_str()?;
let jsx_import_source = compiler_options
.get("jsxImportSourceTypes")
.and_then(|v| v.as_str())
.or_else(|| {
compiler_options
.get("jsxImportSource")
.and_then(|v| v.as_str())
})?;
let jsx_import_source =
import_map.resolve(jsx_import_source, referrer).ok()?;
compiler_options
Expand Down
Loading

0 comments on commit 5c6d924

Please sign in to comment.