mirror of
https://github.com/denoland/deno.git
synced 2024-12-25 16:49:18 -05:00
chore: upgrade deno_ast to 0.5.0 (#12595)
This commit is contained in:
parent
2794d0b7a2
commit
0ec151b8cb
14 changed files with 127 additions and 62 deletions
|
@ -35,9 +35,9 @@
|
|||
"tools/wpt/manifest.json"
|
||||
],
|
||||
"plugins": [
|
||||
"https://plugins.dprint.dev/typescript-0.58.1.wasm",
|
||||
"https://plugins.dprint.dev/json-0.13.0.wasm",
|
||||
"https://plugins.dprint.dev/markdown-0.10.0.wasm",
|
||||
"https://plugins.dprint.dev/typescript-0.59.0.wasm",
|
||||
"https://plugins.dprint.dev/json-0.13.1.wasm",
|
||||
"https://plugins.dprint.dev/markdown-0.11.1.wasm",
|
||||
"https://plugins.dprint.dev/toml-0.5.2.wasm"
|
||||
]
|
||||
}
|
||||
|
|
32
Cargo.lock
generated
32
Cargo.lock
generated
|
@ -695,9 +695,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_ast"
|
||||
version = "0.4.1"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e23902664e99dc1e0f7186ddd26dbf31fc2ab934ef86593700d43052f5ad43bf"
|
||||
checksum = "2ee37af956e0efce7863828eb055208965be06f47959b73c47466e0b5f9a1a9e"
|
||||
dependencies = [
|
||||
"data-url",
|
||||
"dprint-swc-ecma-ast-view",
|
||||
|
@ -781,9 +781,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_doc"
|
||||
version = "0.18.0"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81744eb79bda23580020b2df68a150197312b54c47e11160a65add0534c03ec5"
|
||||
checksum = "08abadd9f3ede74c5ba6e3d9a688ecfe160cf7fb2988ae133ef4e3d591d091e7"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"deno_ast",
|
||||
|
@ -826,9 +826,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_graph"
|
||||
version = "0.9.1"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d7513c22ec28dd1a4eeb82a99fc543c92d7ee2f1a146a0dd6bea7427020eb863"
|
||||
checksum = "6df7e1b135780d9424ce4fb9a8927983d27d2c094922cb84b5fd5d72a4c85b82"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-if 1.0.0",
|
||||
|
@ -862,9 +862,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "deno_lint"
|
||||
version = "0.18.1"
|
||||
version = "0.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dce18a8ca950791a5aa75f6dbd64d3a49a9cb7339877c557ca2df7eb9dba0c5e"
|
||||
checksum = "7c031711a48a3c5ea4ca6103c6d6df456ba3b0bb048fb551f07da4f704e1d844"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"deno_ast",
|
||||
|
@ -1097,9 +1097,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dprint-core"
|
||||
version = "0.46.4"
|
||||
version = "0.47.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df98b7d98583d9d57311b9df81f571f35a6ca3e8675d0128333b2e923dc85bcd"
|
||||
checksum = "75ed0f351c65487deac1ad113edffa75492209dc538e4f85c8d3362088176f3c"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"rustc-hash",
|
||||
|
@ -1108,9 +1108,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dprint-plugin-json"
|
||||
version = "0.13.0"
|
||||
version = "0.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4a32a4eef2c639055370f16a359f0278025058e63193f0ad2340f30bf7ca8361"
|
||||
checksum = "c7e5184c59b6863c21dfd6f8491f895c7f935c41e62ce6464eea57fcb5cb9e60"
|
||||
dependencies = [
|
||||
"dprint-core",
|
||||
"jsonc-parser",
|
||||
|
@ -1119,9 +1119,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dprint-plugin-markdown"
|
||||
version = "0.10.0"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "48b364aed2db4ccf8747dc1d9c7eb52a5e981a705c7aadfddd297fc4c3310772"
|
||||
checksum = "f3d76c5b041062f73b843fd8d4b2adf48aaaf1e0613bbdbb9b42c5b8cf8d586e"
|
||||
dependencies = [
|
||||
"dprint-core",
|
||||
"pulldown-cmark",
|
||||
|
@ -1131,9 +1131,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "dprint-plugin-typescript"
|
||||
version = "0.58.1"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a5749ee5f8d448912fdab331a1535ac29364fc0f94e5c540532a6fa60178ba06"
|
||||
checksum = "a72ba2164e96a10905e57c0ddcf1ec4d7b66bc26226dba413b86016439f0e35f"
|
||||
dependencies = [
|
||||
"deno_ast",
|
||||
"dprint-core",
|
||||
|
|
|
@ -39,11 +39,11 @@ winapi = "0.3.9"
|
|||
winres = "0.1.11"
|
||||
|
||||
[dependencies]
|
||||
deno_ast = { version = "0.4.1", features = ["bundler", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||
deno_ast = { version = "0.5.0", features = ["bundler", "codegen", "dep_graph", "module_specifier", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
|
||||
deno_core = { version = "0.105.0", path = "../core" }
|
||||
deno_doc = "0.18.0"
|
||||
deno_graph = "0.9.1"
|
||||
deno_lint = { version = "0.18.1", features = ["docs"] }
|
||||
deno_doc = "0.19.0"
|
||||
deno_graph = "0.10.0"
|
||||
deno_lint = { version = "0.19.0", features = ["docs"] }
|
||||
deno_runtime = { version = "0.31.0", path = "../runtime" }
|
||||
deno_tls = { version = "0.10.0", path = "../ext/tls" }
|
||||
|
||||
|
@ -52,9 +52,9 @@ base64 = "0.13.0"
|
|||
clap = "2.33.3"
|
||||
data-url = "0.1.0"
|
||||
dissimilar = "1.0.2"
|
||||
dprint-plugin-json = "0.13.0"
|
||||
dprint-plugin-markdown = "0.10.0"
|
||||
dprint-plugin-typescript = "0.58.1"
|
||||
dprint-plugin-json = "0.13.1"
|
||||
dprint-plugin-markdown = "0.11.1"
|
||||
dprint-plugin-typescript = "0.59.0"
|
||||
encoding_rs = "0.8.29"
|
||||
env_logger = "0.8.4"
|
||||
fancy-regex = "0.7.1"
|
||||
|
|
49
cli/emit.rs
49
cli/emit.rs
|
@ -280,8 +280,12 @@ fn get_version(source_bytes: &[u8], config_bytes: &[u8]) -> String {
|
|||
/// Determine if a given media type is emittable or not.
|
||||
fn is_emittable(media_type: &MediaType, include_js: bool) -> bool {
|
||||
match &media_type {
|
||||
MediaType::TypeScript | MediaType::Tsx | MediaType::Jsx => true,
|
||||
MediaType::JavaScript => include_js,
|
||||
MediaType::TypeScript
|
||||
| MediaType::Mts
|
||||
| MediaType::Cts
|
||||
| MediaType::Tsx
|
||||
| MediaType::Jsx => true,
|
||||
MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => include_js,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -375,12 +379,17 @@ pub(crate) fn check_and_maybe_emit(
|
|||
// Sometimes if `tsc` sees a CommonJS file it will _helpfully_ output it
|
||||
// to ESM, which we don't really want to do unless someone has enabled
|
||||
// check_js.
|
||||
if !check_js && *media_type == MediaType::JavaScript {
|
||||
if !check_js
|
||||
&& matches!(
|
||||
media_type,
|
||||
MediaType::JavaScript | MediaType::Cjs | MediaType::Mjs
|
||||
)
|
||||
{
|
||||
log::debug!("skipping emit for {}", specifier);
|
||||
continue;
|
||||
}
|
||||
match emit.media_type {
|
||||
MediaType::JavaScript => {
|
||||
MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs => {
|
||||
let version = get_version(source.as_bytes(), &config_bytes);
|
||||
cache.set(CacheType::Version, &specifier, version)?;
|
||||
cache.set(CacheType::Emit, &specifier, emit.data)?;
|
||||
|
@ -390,7 +399,7 @@ pub(crate) fn check_and_maybe_emit(
|
|||
}
|
||||
// this only occurs with the runtime emit, but we are using the same
|
||||
// code paths, so we handle it here.
|
||||
MediaType::Dts => {
|
||||
MediaType::Dts | MediaType::Dcts | MediaType::Dmts => {
|
||||
cache.set(CacheType::Declaration, &specifier, emit.data)?;
|
||||
}
|
||||
_ => unreachable!(),
|
||||
|
@ -677,10 +686,12 @@ pub(crate) fn valid_emit(
|
|||
.specifiers()
|
||||
.iter()
|
||||
.filter(|(_, r)| match r {
|
||||
Ok((_, MediaType::TypeScript))
|
||||
Ok((_, MediaType::TypeScript | MediaType::Mts | MediaType::Cts))
|
||||
| Ok((_, MediaType::Tsx))
|
||||
| Ok((_, MediaType::Jsx)) => true,
|
||||
Ok((_, MediaType::JavaScript)) => emit_js,
|
||||
Ok((_, MediaType::JavaScript | MediaType::Mjs | MediaType::Cjs)) => {
|
||||
emit_js
|
||||
}
|
||||
_ => false,
|
||||
})
|
||||
.all(|(_, r)| {
|
||||
|
@ -756,9 +767,13 @@ pub(crate) fn to_file_map(
|
|||
if let Some(map) = cache.get(CacheType::SourceMap, &specifier) {
|
||||
files.insert(format!("{}.js.map", specifier), map);
|
||||
}
|
||||
} else if media_type == MediaType::JavaScript
|
||||
|| media_type == MediaType::Unknown
|
||||
{
|
||||
} else if matches!(
|
||||
media_type,
|
||||
MediaType::JavaScript
|
||||
| MediaType::Mjs
|
||||
| MediaType::Cjs
|
||||
| MediaType::Unknown
|
||||
) {
|
||||
if let Some(module) = graph.get(&specifier) {
|
||||
files.insert(specifier.to_string(), module.source.to_string());
|
||||
}
|
||||
|
@ -795,9 +810,13 @@ pub(crate) fn to_module_sources(
|
|||
)
|
||||
// Then if the file is JavaScript (or unknown) and wasn't emitted, we
|
||||
// will load the original source code in the module.
|
||||
} else if media_type == MediaType::JavaScript
|
||||
|| media_type == MediaType::Unknown
|
||||
{
|
||||
} else if matches!(
|
||||
media_type,
|
||||
MediaType::JavaScript
|
||||
| MediaType::Unknown
|
||||
| MediaType::Cjs
|
||||
| MediaType::Mjs
|
||||
) {
|
||||
if let Some(module) = graph.get(&found_specifier) {
|
||||
(
|
||||
requested_specifier.clone(),
|
||||
|
@ -840,8 +859,12 @@ mod tests {
|
|||
fn test_is_emittable() {
|
||||
assert!(is_emittable(&MediaType::TypeScript, false));
|
||||
assert!(!is_emittable(&MediaType::Dts, false));
|
||||
assert!(!is_emittable(&MediaType::Dcts, false));
|
||||
assert!(!is_emittable(&MediaType::Dmts, false));
|
||||
assert!(is_emittable(&MediaType::Tsx, false));
|
||||
assert!(!is_emittable(&MediaType::JavaScript, false));
|
||||
assert!(!is_emittable(&MediaType::Cjs, false));
|
||||
assert!(!is_emittable(&MediaType::Mjs, false));
|
||||
assert!(is_emittable(&MediaType::JavaScript, true));
|
||||
assert!(is_emittable(&MediaType::Jsx, false));
|
||||
assert!(!is_emittable(&MediaType::Json, false));
|
||||
|
|
|
@ -283,9 +283,10 @@ impl FileFetcher {
|
|||
map_content_type(specifier, maybe_content_type);
|
||||
let source = strip_shebang(get_source_from_bytes(bytes, maybe_charset)?);
|
||||
let maybe_types = match media_type {
|
||||
MediaType::JavaScript | MediaType::Jsx => {
|
||||
headers.get("x-typescript-types").cloned()
|
||||
}
|
||||
MediaType::JavaScript
|
||||
| MediaType::Cjs
|
||||
| MediaType::Mjs
|
||||
| MediaType::Jsx => headers.get("x-typescript-types").cloned(),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
|
@ -745,13 +746,17 @@ mod tests {
|
|||
// Extension only
|
||||
(file_url!("/foo/bar.ts"), None, MediaType::TypeScript, None),
|
||||
(file_url!("/foo/bar.tsx"), None, MediaType::Tsx, None),
|
||||
(file_url!("/foo/bar.d.cts"), None, MediaType::Dcts, None),
|
||||
(file_url!("/foo/bar.d.mts"), None, MediaType::Dmts, None),
|
||||
(file_url!("/foo/bar.d.ts"), None, MediaType::Dts, None),
|
||||
(file_url!("/foo/bar.js"), None, MediaType::JavaScript, None),
|
||||
(file_url!("/foo/bar.jsx"), None, MediaType::Jsx, None),
|
||||
(file_url!("/foo/bar.json"), None, MediaType::Json, None),
|
||||
(file_url!("/foo/bar.wasm"), None, MediaType::Wasm, None),
|
||||
(file_url!("/foo/bar.cjs"), None, MediaType::JavaScript, None),
|
||||
(file_url!("/foo/bar.mjs"), None, MediaType::JavaScript, None),
|
||||
(file_url!("/foo/bar.cjs"), None, MediaType::Cjs, None),
|
||||
(file_url!("/foo/bar.mjs"), None, MediaType::Mjs, None),
|
||||
(file_url!("/foo/bar.cts"), None, MediaType::Cts, None),
|
||||
(file_url!("/foo/bar.mts"), None, MediaType::Mts, None),
|
||||
(file_url!("/foo/bar"), None, MediaType::Unknown, None),
|
||||
// Media type no extension
|
||||
(
|
||||
|
@ -884,7 +889,7 @@ mod tests {
|
|||
(
|
||||
"https://deno.land/x/mod.d.ts",
|
||||
Some("application/javascript".to_string()),
|
||||
MediaType::JavaScript,
|
||||
MediaType::Dts,
|
||||
None,
|
||||
),
|
||||
(
|
||||
|
|
|
@ -250,6 +250,7 @@ impl Document {
|
|||
fn is_diagnosable(&self) -> bool {
|
||||
matches!(
|
||||
self.media_type(),
|
||||
// todo(#12410): Update with new media types for TS 4.5
|
||||
MediaType::JavaScript
|
||||
| MediaType::Jsx
|
||||
| MediaType::TypeScript
|
||||
|
|
|
@ -327,6 +327,7 @@ impl Inner {
|
|||
if specifier.scheme() == "asset" {
|
||||
matches!(
|
||||
MediaType::from(specifier),
|
||||
// todo(#12410): Update with new media types for TS 4.5
|
||||
MediaType::JavaScript
|
||||
| MediaType::Jsx
|
||||
| MediaType::TypeScript
|
||||
|
|
|
@ -73,7 +73,7 @@ unitTest(function webAssemblyExists() {
|
|||
|
||||
declare global {
|
||||
namespace Deno {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
// deno-lint-ignore no-explicit-any, no-var
|
||||
var core: any;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ unitTest(async function sendAsyncStackTrace() {
|
|||
|
||||
declare global {
|
||||
namespace Deno {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
// deno-lint-ignore no-explicit-any, no-var
|
||||
var core: any;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ unitTest({ permissions: { read: true } }, async function resourcesFile() {
|
|||
Object.keys(resourcesBefore).length + 1,
|
||||
);
|
||||
const newRid = +Object.keys(resourcesAfter).find((rid): boolean => {
|
||||
return !resourcesBefore.hasOwnProperty(rid);
|
||||
return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid);
|
||||
})!;
|
||||
assertEquals(resourcesAfter[newRid], "fsFile");
|
||||
});
|
||||
|
|
|
@ -515,8 +515,12 @@ fn extract_files_from_regex_blocks(
|
|||
|
||||
match attributes.get(0) {
|
||||
Some(&"js") => MediaType::JavaScript,
|
||||
Some(&"mjs") => MediaType::Mjs,
|
||||
Some(&"cjs") => MediaType::Cjs,
|
||||
Some(&"jsx") => MediaType::Jsx,
|
||||
Some(&"ts") => MediaType::TypeScript,
|
||||
Some(&"mts") => MediaType::Mts,
|
||||
Some(&"cts") => MediaType::Cts,
|
||||
Some(&"tsx") => MediaType::Tsx,
|
||||
Some(&"") => media_type,
|
||||
_ => MediaType::Unknown,
|
||||
|
|
35
cli/tsc.rs
35
cli/tsc.rs
|
@ -140,8 +140,35 @@ fn get_tsc_media_type(specifier: &ModuleSpecifier) -> MediaType {
|
|||
}
|
||||
MediaType::TypeScript
|
||||
}
|
||||
Some("mts") => {
|
||||
if let Some(os_str) = path.file_stem() {
|
||||
if let Some(file_name) = os_str.to_str() {
|
||||
if file_name.ends_with(".d") {
|
||||
// todo(#12410): Use Dmts for TS 4.5
|
||||
return MediaType::Dts;
|
||||
}
|
||||
}
|
||||
}
|
||||
// todo(#12410): Use Mts for TS 4.5
|
||||
MediaType::TypeScript
|
||||
}
|
||||
Some("cts") => {
|
||||
if let Some(os_str) = path.file_stem() {
|
||||
if let Some(file_name) = os_str.to_str() {
|
||||
if file_name.ends_with(".d") {
|
||||
// todo(#12410): Use Dcts for TS 4.5
|
||||
return MediaType::Dts;
|
||||
}
|
||||
}
|
||||
}
|
||||
// todo(#12410): Use Cts for TS 4.5
|
||||
MediaType::TypeScript
|
||||
}
|
||||
Some("tsx") => MediaType::Tsx,
|
||||
Some("js") => MediaType::JavaScript,
|
||||
// todo(#12410): Use correct media type for TS 4.5
|
||||
Some("mjs") => MediaType::JavaScript,
|
||||
Some("cjs") => MediaType::JavaScript,
|
||||
Some("jsx") => MediaType::Jsx,
|
||||
_ => MediaType::Unknown,
|
||||
},
|
||||
|
@ -707,12 +734,16 @@ mod tests {
|
|||
fn test_get_tsc_media_type() {
|
||||
let fixtures = vec![
|
||||
("file:///a.ts", MediaType::TypeScript),
|
||||
("file:///a.cts", MediaType::TypeScript),
|
||||
("file:///a.mts", MediaType::TypeScript),
|
||||
("file:///a.tsx", MediaType::Tsx),
|
||||
("file:///a.d.ts", MediaType::Dts),
|
||||
("file:///a.d.cts", MediaType::Dts),
|
||||
("file:///a.d.mts", MediaType::Dts),
|
||||
("file:///a.js", MediaType::JavaScript),
|
||||
("file:///a.jsx", MediaType::Jsx),
|
||||
("file:///a.cjs", MediaType::Unknown),
|
||||
("file:///a.mjs", MediaType::Unknown),
|
||||
("file:///a.cjs", MediaType::JavaScript),
|
||||
("file:///a.mjs", MediaType::JavaScript),
|
||||
("file:///a.json", MediaType::Unknown),
|
||||
("file:///a.wasm", MediaType::Unknown),
|
||||
("file:///a.js.map", MediaType::Unknown),
|
||||
|
|
|
@ -48,10 +48,10 @@ when encoding/decoding.
|
|||
- [ ] Experiment with KeyCache to optimize struct keys
|
||||
- [ ] Experiment with external v8 strings
|
||||
- [ ] Explore using
|
||||
[json-stringifier.cc](https://chromium.googlesource.com/v8/v8/+/refs/heads/master/src/json/json-stringifier.cc)'s
|
||||
fast-paths for arrays
|
||||
[json-stringifier.cc](https://chromium.googlesource.com/v8/v8/+/refs/heads/master/src/json/json-stringifier.cc)'s
|
||||
fast-paths for arrays
|
||||
- [ ] Improve tests to test parity with `serde_json` (should be mostly
|
||||
interchangeable)
|
||||
interchangeable)
|
||||
- [ ] Consider a `Payload` type that's deserializable by itself (holds scope &
|
||||
value)
|
||||
value)
|
||||
- [ ] Ensure we return errors instead of panicking on `.unwrap()`s
|
||||
|
|
|
@ -4,17 +4,17 @@
|
|||
|
||||
- [ ] An up to date stable Rust toolchain
|
||||
- [ ] A binary version of `deno` available (hopefully built from `main`) that is
|
||||
going to be available throughout any local building you might do.
|
||||
going to be available throughout any local building you might do.
|
||||
- [ ] Forks and local clones of
|
||||
[`denoland/deno`](https://github.com/denoland/deno/),
|
||||
[`denoland/deno_std`](https://github.com/denoland/deno_std/),
|
||||
[`denoland/dotland`](https://github.com/denoland/dotland/) and
|
||||
[`denoland/deno_docker`](https://github.com/denoland/deno_docker/)
|
||||
[`denoland/deno`](https://github.com/denoland/deno/),
|
||||
[`denoland/deno_std`](https://github.com/denoland/deno_std/),
|
||||
[`denoland/dotland`](https://github.com/denoland/dotland/) and
|
||||
[`denoland/deno_docker`](https://github.com/denoland/deno_docker/)
|
||||
- [ ] Ensure that external dependencies are up-to date in `denoland/deno` (e.g.
|
||||
`rusty_v8`, `serde_v8`, `deno_doc`, `deno_lint`).
|
||||
`rusty_v8`, `serde_v8`, `deno_doc`, `deno_lint`).
|
||||
- [ ] Ownership access on crates.io for the 19 (🙀) crates that you will be
|
||||
publishing. (Don't worry too much though as the main script publishing 18 of
|
||||
the crates allows recovery)
|
||||
publishing. (Don't worry too much though as the main script publishing 18
|
||||
of the crates allows recovery)
|
||||
- [ ] Lot's of ☕
|
||||
|
||||
**During this process `main` branch (or any other branch that you're creating
|
||||
|
|
Loading…
Reference in a new issue