Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(info): Remove emit and map keys from json output #17816

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cli/tests/testdata/info/076_info_json_deps_order.out
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
],
"local": "[WILDCARD]076_info_json_deps_order.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/076_info_json_deps_order.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/076_info_json_deps_order.ts"
"size": 81
},
{
"kind": "esm",
Expand Down Expand Up @@ -65,9 +65,9 @@
}
],
"local": "[WILDCARD]A.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/recursive_imports/A.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/recursive_imports/A.ts"
"size": 108
},
{
"kind": "esm",
Expand Down Expand Up @@ -106,9 +106,9 @@
}
],
"local": "[WILDCARD]B.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/recursive_imports/B.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/recursive_imports/B.ts"
"size": 108
},
{
"kind": "esm",
Expand Down Expand Up @@ -147,16 +147,16 @@
}
],
"local": "[WILDCARD]C.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/recursive_imports/C.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/recursive_imports/C.ts"
"size": 126
},
{
"kind": "esm",
"local": "[WILDCARD]common.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/recursive_imports/common.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/recursive_imports/common.ts"
"size": 28
}
],
"redirects": {},
Expand Down
16 changes: 8 additions & 8 deletions cli/tests/testdata/info/json_output/main.out
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
}
],
"local": "[WILDCARD]main.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/json_output/main.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/json_output/main.ts"
"size": 215
},
{
"kind": "esm",
Expand All @@ -49,16 +49,16 @@
}
],
"local": "[WILDCARD]mod1.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/subdir/mod1.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/subdir/mod1.ts"
"size": 308
},
{
"kind": "esm",
"local": "[WILDCARD]print_hello.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/subdir/print_hello.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/subdir/print_hello.ts"
"size": 57
},
{
"kind": "esm",
Expand All @@ -81,9 +81,9 @@
}
],
"local": "[WILDCARD]mod2.ts",
[WILDCARD]
"specifier": "file://[WILDCARD]/subdir/subdir2/mod2.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/subdir/subdir2/mod2.ts"
"size": 157
}
],
"redirects": {},
Expand Down
6 changes: 2 additions & 4 deletions cli/tests/testdata/npm/cjs_with_deps/main_info_json.out
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@
}
],
"local": "[WILDCARD]main.js",
"emit": null,
"map": null,
"size": 325,
"specifier": "[WILDCARD]/main.js",
"mediaType": "JavaScript",
"specifier": "[WILDCARD]/main.js"
"size": 325
}
],
"redirects": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@
}
],
"local": "[WILDCARD]main.ts",
"emit": null,
"map": null,
"size": 171,
"specifier": "file://[WILDCARD]/main.ts",
"mediaType": "TypeScript",
"specifier": "file://[WILDCARD]/main.ts"
"size": 171
}
],
"redirects": {
Expand Down
6 changes: 6 additions & 0 deletions cli/tools/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ fn add_npm_packages_to_json(
}

for module in modules.iter_mut() {
// Remove redundant, unused keys.
if let Some(module) = module.as_object_mut() {
module.remove("emit");
module.remove("map");
}

let dependencies = module
.get_mut("dependencies")
.and_then(|d| d.as_array_mut());
Expand Down