From bd9f137b1bfb5bc3b215515ff9305e70a638daf9 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 29 Aug 2021 21:48:14 -0700 Subject: latest Former-commit-id: 096ec1222ad723d006b0151f10cb0c1b95e2bfd3 --- src/js_parser/js_parser.zig | 104 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 93 insertions(+), 11 deletions(-) (limited to 'src/js_parser/js_parser.zig') diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index 760d3ec2b..83a1b0127 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -130,7 +130,7 @@ pub const ImportScanner = struct { // // const keep_unused_imports = !p.options.trim_unused_imports; var did_remove_star_loc = false; - const keep_unused_imports = false; + const keep_unused_imports = !p.options.ts; // TypeScript always trims unused imports. This is important for // correctness since some imports might be fake (only in the type @@ -205,11 +205,7 @@ pub const ImportScanner = struct { } } - if (items_end < st.items.len - 1) { - var list = List(js_ast.ClauseItem).fromOwnedSlice(p.allocator, st.items); - list.shrinkAndFree(items_end); - st.items = list.toOwnedSlice(); - } + st.items = st.items[0..items_end]; } // -- Original Comment -- @@ -285,7 +281,7 @@ pub const ImportScanner = struct { // it's really stupid to import all 1,000 components from that design system // when you just want