diff --git a/crates/oxc_codegen/src/gen.rs b/crates/oxc_codegen/src/gen.rs index 97cb7f9dc90af..416523e966a2e 100644 --- a/crates/oxc_codegen/src/gen.rs +++ b/crates/oxc_codegen/src/gen.rs @@ -43,7 +43,13 @@ impl<'a, const MINIFY: bool> Gen for Program<'a> { if let Some(hashbang) = &self.hashbang { hashbang.gen(p, ctx); } - p.print_directives_and_statements(Some(&self.directives), &self.body, ctx); + for directive in &self.directives { + directive.gen(p, ctx); + } + for stmt in &self.body { + stmt.gen(p, ctx); + p.print_semicolon_if_needed(); + } } } @@ -64,7 +70,8 @@ impl<'a, const MINIFY: bool> Gen for Directive<'a> { p.wrap_quote(|p, _| { p.print_str(self.directive.as_str()); }); - p.print_semicolon_after_statement(); + p.print_char(b';'); + p.print_soft_newline(); } } @@ -112,9 +119,9 @@ impl<'a, const MINIFY: bool> Gen for Statement<'a> { decl.gen(p, ctx); p.print_soft_newline(); } - Self::UsingDeclaration(declaration) => { + Self::UsingDeclaration(decl) => { p.print_indent(); - declaration.gen(p, ctx); + decl.gen(p, ctx); p.print_semicolon_after_statement(); } Self::TSModuleDeclaration(decl) => { @@ -560,11 +567,9 @@ impl Gen for DebuggerStatement { impl<'a, const MINIFY: bool> Gen for UsingDeclaration<'a> { fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) { if self.is_await { - p.print_str("await"); - p.print_soft_space(); + p.print_str("await "); } - p.print_str("using"); - p.print_soft_space(); + p.print_str("using "); p.print_list(&self.declarations, ctx); } } @@ -665,7 +670,13 @@ impl<'a, const MINIFY: bool> Gen for Function<'a> { impl<'a, const MINIFY: bool> Gen for FunctionBody<'a> { fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) { p.print_curly_braces(self.span, self.is_empty(), |p| { - p.print_directives_and_statements(Some(&self.directives), &self.statements, ctx); + for directive in &self.directives { + directive.gen(p, ctx); + } + for stmt in &self.statements { + p.print_semicolon_if_needed(); + stmt.gen(p, ctx); + } }); p.needs_semicolon = false; } @@ -711,9 +722,9 @@ impl<'a, const MINIFY: bool> Gen for ImportDeclaration<'a> { p.print_soft_space(); p.print_str("from"); p.print_soft_space(); - p.print_char(b'\''); + p.print_char(b'"'); p.print_str(self.source.value.as_str()); - p.print_char(b'\''); + p.print_char(b'"'); if self.with_clause.is_some() { p.print_hard_space(); } @@ -996,7 +1007,10 @@ impl<'a, const MINIFY: bool> Gen for ExportDefaultDeclarationKind<'a> { self.to_expression().gen_expr(p, Precedence::Assign, Context::default()); p.print_semicolon_after_statement(); } - Self::FunctionDeclaration(fun) => fun.gen(p, ctx), + Self::FunctionDeclaration(fun) => { + fun.gen(p, ctx); + p.print_soft_newline(); + } Self::ClassDeclaration(class) => { class.gen(p, ctx); p.print_soft_newline(); @@ -1477,23 +1491,36 @@ impl<'a, const MINIFY: bool> Gen for ArrayExpression<'a> { impl<'a, const MINIFY: bool> GenExpr for ObjectExpression<'a> { fn gen_expr(&self, p: &mut Codegen<{ MINIFY }>, _precedence: Precedence, ctx: Context) { let n = p.code_len(); - p.wrap(p.start_of_stmt == n || p.start_of_arrow_expr == n, |p| { - let single_line = self.properties.len() <= 1; - p.print_curly_braces(self.span, single_line, |p| { - for (index, item) in self.properties.iter().enumerate() { - if index != 0 { - p.print_comma(); - p.print_soft_newline(); - } - if !single_line { - p.print_indent(); - } - item.gen(p, ctx); + let len = self.properties.len(); + let is_multi_line = len > 1; + let wrap = p.start_of_stmt == n || p.start_of_arrow_expr == n; + p.wrap(wrap, |p| { + p.add_source_mapping(self.span.start); + p.print_char(b'{'); + if is_multi_line { + p.indent(); + } + for (i, item) in self.properties.iter().enumerate() { + if i != 0 { + p.print_comma(); } - if !single_line { + if is_multi_line { p.print_soft_newline(); + p.print_indent(); + } else { + p.print_soft_space(); } - }); + item.gen(p, ctx); + } + if is_multi_line { + p.print_soft_newline(); + p.dedent(); + p.print_indent(); + } else if len > 0 { + p.print_soft_space(); + } + p.add_source_mapping(self.span.end); + p.print_char(b'}'); }); } } @@ -1555,7 +1582,7 @@ impl<'a, const MINIFY: bool> Gen for ObjectProperty<'a> { let mut shorthand = false; if let PropertyKey::StaticIdentifier(key) = &self.key { if let Expression::Identifier(ident) = self.value.without_parenthesized() { - if key.name == p.get_identifier_reference_name(ident) { + if key.name == p.get_identifier_reference_name(ident) && key.name != "__proto__" { shorthand = true; } } @@ -1981,7 +2008,7 @@ impl<'a, const MINIFY: bool> Gen for AssignmentTargetRest<'a> { impl<'a, const MINIFY: bool> GenExpr for SequenceExpression<'a> { fn gen_expr(&self, p: &mut Codegen<{ MINIFY }>, precedence: Precedence, _ctx: Context) { p.wrap(precedence > self.precedence(), |p| { - p.print_expressions(&self.expressions, Precedence::Assign, Context::default()); + p.print_expressions(&self.expressions, Precedence::Comma, Context::default()); }); } } @@ -2278,17 +2305,17 @@ impl<'a, const MINIFY: bool> Gen for JSXAttributeItem<'a> { impl<'a, const MINIFY: bool> Gen for JSXOpeningElement<'a> { fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) { p.add_source_mapping(self.span.start); - p.print_str("<"); + p.print_char(b'<'); self.name.gen(p, ctx); for attr in &self.attributes { p.print_hard_space(); attr.gen(p, ctx); } if self.self_closing { - p.print_str("/>"); - } else { - p.print_char(b'>'); + p.print_soft_space(); + p.print_str("/"); } + p.print_char(b'>'); } } @@ -2490,9 +2517,12 @@ impl<'a, const MINIFY: bool> Gen for AccessorProperty<'a> { if self.r#static { p.print_str("static "); } - p.print_str("accessor "); + p.print_str("accessor"); if self.computed { + p.print_soft_space(); p.print_char(b'['); + } else { + p.print_hard_space(); } self.key.gen(p, ctx); if self.computed { @@ -2559,10 +2589,22 @@ impl<'a, const MINIFY: bool> Gen for BindingProperty<'a> { let mut shorthand = false; if let PropertyKey::StaticIdentifier(key) = &self.key { - if let BindingPatternKind::BindingIdentifier(ident) = &self.value.kind { - if key.name == p.get_binding_identifier_name(ident) { + match &self.value.kind { + BindingPatternKind::BindingIdentifier(ident) + if key.name == p.get_binding_identifier_name(ident) => + { shorthand = true; } + BindingPatternKind::AssignmentPattern(assignment_pattern) => { + if let BindingPatternKind::BindingIdentifier(ident) = + &assignment_pattern.left.kind + { + if key.name == p.get_binding_identifier_name(ident) { + shorthand = true; + } + } + } + _ => {} } } @@ -2595,9 +2637,7 @@ impl<'a, const MINIFY: bool> Gen for ArrayPattern<'a> { for (index, item) in self.elements.iter().enumerate() { if index != 0 { p.print_comma(); - if item.is_some() { - p.print_soft_space(); - } + p.print_soft_space(); } if let Some(item) = item { item.gen(p, ctx); @@ -3365,8 +3405,15 @@ impl<'a, const MINIFY: bool> Gen for TSModuleBlock<'a> { fn gen(&self, p: &mut Codegen<{ MINIFY }>, ctx: Context) { let is_empty = self.directives.is_empty() && self.body.is_empty(); p.print_curly_braces(self.span, is_empty, |p| { - p.print_directives_and_statements(Some(&self.directives), &self.body, ctx); + for directive in &self.directives { + directive.gen(p, ctx); + } + for stmt in &self.body { + p.print_semicolon_if_needed(); + stmt.gen(p, ctx); + } }); + p.needs_semicolon = false; } } diff --git a/crates/oxc_codegen/src/lib.rs b/crates/oxc_codegen/src/lib.rs index 30838e45df420..34084254043bb 100644 --- a/crates/oxc_codegen/src/lib.rs +++ b/crates/oxc_codegen/src/lib.rs @@ -14,10 +14,7 @@ use std::{borrow::Cow, ops::Range}; use rustc_hash::FxHashMap; use oxc_ast::{ - ast::{ - BindingIdentifier, BlockStatement, Directive, Expression, IdentifierReference, Program, - Statement, - }, + ast::{BindingIdentifier, BlockStatement, Expression, IdentifierReference, Program, Statement}, Comment, Trivias, }; use oxc_mangler::Mangler; @@ -392,7 +389,10 @@ impl<'a, const MINIFY: bool> Codegen<'a, MINIFY> { fn print_block_statement(&mut self, stmt: &BlockStatement<'_>, ctx: Context) { self.print_curly_braces(stmt.span, stmt.body.is_empty(), |p| { - p.print_directives_and_statements(None, &stmt.body, ctx); + for stmt in &stmt.body { + p.print_semicolon_if_needed(); + stmt.gen(p, ctx); + } }); self.needs_semicolon = false; } @@ -500,33 +500,6 @@ impl<'a, const MINIFY: bool> Codegen<'a, MINIFY> { self.print_char(self.quote); } - fn print_directives_and_statements( - &mut self, - directives: Option<&[Directive]>, - statements: &[Statement<'_>], - ctx: Context, - ) { - if let Some(directives) = directives { - if directives.is_empty() { - if let Some(Statement::ExpressionStatement(s)) = statements.first() { - if matches!(s.expression.get_inner_expression(), Expression::StringLiteral(_)) { - self.print_semicolon(); - self.print_soft_newline(); - } - } - } else { - for directive in directives { - directive.gen(self, ctx); - self.print_semicolon_if_needed(); - } - } - } - for stmt in statements { - self.print_semicolon_if_needed(); - stmt.gen(self, ctx); - } - } - fn add_source_mapping(&mut self, position: u32) { if let Some(sourcemap_builder) = self.sourcemap_builder.as_mut() { sourcemap_builder.add_source_mapping(&self.code, position, None); diff --git a/crates/oxc_codegen/tests/integration/esbuild.rs b/crates/oxc_codegen/tests/integration/esbuild.rs index 1986f5af91e4a..529f07915cdda 100644 --- a/crates/oxc_codegen/tests/integration/esbuild.rs +++ b/crates/oxc_codegen/tests/integration/esbuild.rs @@ -3,17 +3,16 @@ use crate::tester::{test, test_minify}; #[test] -#[ignore] fn test_number() { // Check "1eN" test("x = 1e-100", "x = 1e-100;\n"); test("x = 1e-4", "x = 1e-4;\n"); test("x = 1e-3", "x = 1e-3;\n"); - test("x = 1e-2", "x = 0.01;\n"); - test("x = 1e-1", "x = 0.1;\n"); - test("x = 1e0", "x = 1;\n"); - test("x = 1e1", "x = 10;\n"); - test("x = 1e2", "x = 100;\n"); + // test("x = 1e-2", "x = 0.01;\n"); + // test("x = 1e-1", "x = 0.1;\n"); + // test("x = 1e0", "x = 1;\n"); + // test("x = 1e1", "x = 10;\n"); + // test("x = 1e2", "x = 100;\n"); test("x = 1e3", "x = 1e3;\n"); test("x = 1e4", "x = 1e4;\n"); test("x = 1e100", "x = 1e100;\n"); @@ -28,22 +27,22 @@ fn test_number() { test_minify("x = 1e2", "x=100;"); test_minify("x = 1e3", "x=1e3;"); test_minify("x = 1e4", "x=1e4;"); - test_minify("x = 1e100", "x=1e100;"); + // test_minify("x = 1e100", "x=1e100;"); // Check "12eN" test("x = 12e-100", "x = 12e-100;\n"); test("x = 12e-5", "x = 12e-5;\n"); test("x = 12e-4", "x = 12e-4;\n"); - test("x = 12e-3", "x = 0.012;\n"); - test("x = 12e-2", "x = 0.12;\n"); - test("x = 12e-1", "x = 1.2;\n"); - test("x = 12e0", "x = 12;\n"); - test("x = 12e1", "x = 120;\n"); - test("x = 12e2", "x = 1200;\n"); + // test("x = 12e-3", "x = 0.012;\n"); + // test("x = 12e-2", "x = 0.12;\n"); + // test("x = 12e-1", "x = 1.2;\n"); + // test("x = 12e0", "x = 12;\n"); + // test("x = 12e1", "x = 120;\n"); + // test("x = 12e2", "x = 1200;\n"); test("x = 12e3", "x = 12e3;\n"); test("x = 12e4", "x = 12e4;\n"); test("x = 12e100", "x = 12e100;\n"); - test_minify("x = 12e-100", "x=12e-100;"); + // test_minify("x = 12e-100", "x=12e-100;"); test_minify("x = 12e-6", "x=12e-6;"); test_minify("x = 12e-5", "x=12e-5;"); test_minify("x = 12e-4", "x=.0012;"); @@ -55,7 +54,7 @@ fn test_number() { test_minify("x = 12e2", "x=1200;"); test_minify("x = 12e3", "x=12e3;"); test_minify("x = 12e4", "x=12e4;"); - test_minify("x = 12e100", "x=12e100;"); + // test_minify("x = 12e100", "x=12e100;"); // Check cases for "A.BeX" => "ABeY" simplification test("x = 123456789", "x = 123456789;\n"); @@ -66,62 +65,62 @@ fn test_number() { test("x = 10000123456789", "x = 10000123456789;\n"); test("x = 100000123456789", "x = 100000123456789;\n"); test("x = 1000000123456789", "x = 1000000123456789;\n"); - test("x = 10000000123456789", "x = 10000000123456788;\n"); - test("x = 100000000123456789", "x = 100000000123456780;\n"); - test("x = 1000000000123456789", "x = 1000000000123456800;\n"); - test("x = 10000000000123456789", "x = 10000000000123458e3;\n"); - test("x = 100000000000123456789", "x = 10000000000012345e4;\n"); + // test("x = 10000000123456789", "x = 10000000123456788;\n"); + // test("x = 100000000123456789", "x = 100000000123456780;\n"); + // test("x = 1000000000123456789", "x = 1000000000123456800;\n"); + // test("x = 10000000000123456789", "x = 10000000000123458e3;\n"); + // test("x = 100000000000123456789", "x = 10000000000012345e4;\n"); // Check numbers around the ends of various integer ranges. These were // crashing in the WebAssembly build due to a bug in the Go runtime. // int32 - test("x = 0x7fff_ffff", "x = 2147483647;\n"); - test("x = 0x8000_0000", "x = 2147483648;\n"); - test("x = 0x8000_0001", "x = 2147483649;\n"); - test("x = -0x7fff_ffff", "x = -2147483647;\n"); - test("x = -0x8000_0000", "x = -2147483648;\n"); - test("x = -0x8000_0001", "x = -2147483649;\n"); + // test("x = 0x7fff_ffff", "x = 2147483647;\n"); + // test("x = 0x8000_0000", "x = 2147483648;\n"); + // test("x = 0x8000_0001", "x = 2147483649;\n"); + // test("x = -0x7fff_ffff", "x = -2147483647;\n"); + // test("x = -0x8000_0000", "x = -2147483648;\n"); + // test("x = -0x8000_0001", "x = -2147483649;\n"); // uint32 - test("x = 0xffff_ffff", "x = 4294967295;\n"); - test("x = 0x1_0000_0000", "x = 4294967296;\n"); - test("x = 0x1_0000_0001", "x = 4294967297;\n"); - test("x = -0xffff_ffff", "x = -4294967295;\n"); - test("x = -0x1_0000_0000", "x = -4294967296;\n"); - test("x = -0x1_0000_0001", "x = -4294967297;\n"); + // test("x = 0xffff_ffff", "x = 4294967295;\n"); + // test("x = 0x1_0000_0000", "x = 4294967296;\n"); + // test("x = 0x1_0000_0001", "x = 4294967297;\n"); + // test("x = -0xffff_ffff", "x = -4294967295;\n"); + // test("x = -0x1_0000_0000", "x = -4294967296;\n"); + // test("x = -0x1_0000_0001", "x = -4294967297;\n"); // int64 - test("x = 0x7fff_ffff_ffff_fdff", "x = 9223372036854775e3;\n"); - test("x = 0x8000_0000_0000_0000", "x = 9223372036854776e3;\n"); - test("x = 0x8000_0000_0000_3000", "x = 9223372036854788e3;\n"); - test("x = -0x7fff_ffff_ffff_fdff", "x = -9223372036854775e3;\n"); - test("x = -0x8000_0000_0000_0000", "x = -9223372036854776e3;\n"); - test("x = -0x8000_0000_0000_3000", "x = -9223372036854788e3;\n"); + // test("x = 0x7fff_ffff_ffff_fdff", "x = 9223372036854775e3;\n"); + // test("x = 0x8000_0000_0000_0000", "x = 9223372036854776e3;\n"); + // test("x = 0x8000_0000_0000_3000", "x = 9223372036854788e3;\n"); + // test("x = -0x7fff_ffff_ffff_fdff", "x = -9223372036854775e3;\n"); + // test("x = -0x8000_0000_0000_0000", "x = -9223372036854776e3;\n"); + // test("x = -0x8000_0000_0000_3000", "x = -9223372036854788e3;\n"); // uint64 - test("x = 0xffff_ffff_ffff_fbff", "x = 1844674407370955e4;\n"); - test("x = 0x1_0000_0000_0000_0000", "x = 18446744073709552e3;\n"); - test("x = 0x1_0000_0000_0000_1000", "x = 18446744073709556e3;\n"); - test("x = -0xffff_ffff_ffff_fbff", "x = -1844674407370955e4;\n"); - test("x = -0x1_0000_0000_0000_0000", "x = -18446744073709552e3;\n"); - test("x = -0x1_0000_0000_0000_1000", "x = -18446744073709556e3;\n"); + // test("x = 0xffff_ffff_ffff_fbff", "x = 1844674407370955e4;\n"); + // test("x = 0x1_0000_0000_0000_0000", "x = 18446744073709552e3;\n"); + // test("x = 0x1_0000_0000_0000_1000", "x = 18446744073709556e3;\n"); + // test("x = -0xffff_ffff_ffff_fbff", "x = -1844674407370955e4;\n"); + // test("x = -0x1_0000_0000_0000_0000", "x = -18446744073709552e3;\n"); + // test("x = -0x1_0000_0000_0000_1000", "x = -18446744073709556e3;\n"); // Check the hex vs. decimal decision boundary when minifying - test("x = 999999999999", "x = 999999999999;\n"); - test("x = 1000000000001", "x = 1000000000001;\n"); - test("x = 0x0FFF_FFFF_FFFF_FF80", "x = 1152921504606846800;\n"); - test("x = 0x1000_0000_0000_0000", "x = 1152921504606847e3;\n"); - test("x = 0xFFFF_FFFF_FFFF_F000", "x = 18446744073709548e3;\n"); - test("x = 0xFFFF_FFFF_FFFF_F800", "x = 1844674407370955e4;\n"); - test("x = 0xFFFF_FFFF_FFFF_FFFF", "x = 18446744073709552e3;\n"); - test_minify("x = 999999999999", "x=999999999999;"); - test_minify("x = 1000000000001", "x=0xe8d4a51001;"); - test_minify("x = 0x0FFF_FFFF_FFFF_FF80", "x=0xfffffffffffff80;"); - test_minify("x = 0x1000_0000_0000_0000", "x=1152921504606847e3;"); - test_minify("x = 0xFFFF_FFFF_FFFF_F000", "x=0xfffffffffffff000;"); - test_minify("x = 0xFFFF_FFFF_FFFF_F800", "x=1844674407370955e4;"); - test_minify("x = 0xFFFF_FFFF_FFFF_FFFF", "x=18446744073709552e3;"); + // test("x = 999999999999", "x = 999999999999;\n"); + // test("x = 1000000000001", "x = 1000000000001;\n"); + // test("x = 0x0FFF_FFFF_FFFF_FF80", "x = 1152921504606846800;\n"); + // test("x = 0x1000_0000_0000_0000", "x = 1152921504606847e3;\n"); + // test("x = 0xFFFF_FFFF_FFFF_F000", "x = 18446744073709548e3;\n"); + // test("x = 0xFFFF_FFFF_FFFF_F800", "x = 1844674407370955e4;\n"); + // test("x = 0xFFFF_FFFF_FFFF_FFFF", "x = 18446744073709552e3;\n"); + // test_minify("x = 999999999999", "x=999999999999;"); + // test_minify("x = 1000000000001", "x=0xe8d4a51001;"); + // test_minify("x = 0x0FFF_FFFF_FFFF_FF80", "x=0xfffffffffffff80;"); + // test_minify("x = 0x1000_0000_0000_0000", "x=1152921504606847e3;"); + // test_minify("x = 0xFFFF_FFFF_FFFF_F000", "x=0xfffffffffffff000;"); + // test_minify("x = 0xFFFF_FFFF_FFFF_F800", "x=1844674407370955e4;"); + // test_minify("x = 0xFFFF_FFFF_FFFF_FFFF", "x=18446744073709552e3;"); // Check printing a space in between a number and a subsequent "." test_minify("x = 0.0001 .y", "x=1e-4.y;"); @@ -137,7 +136,6 @@ fn test_number() { } #[test] -#[ignore] fn test_array() { test("[]", "[];\n"); test("[,]", "[,];\n"); @@ -145,11 +143,10 @@ fn test_array() { } #[test] -#[ignore] fn test_splat() { test("[...(a, b)]", "[...(a, b)];\n"); test("x(...(a, b))", "x(...(a, b));\n"); - test("({...(a, b)})", "({ ...(a, b) });\n"); + // test("({...(a, b)})", "({ ...(a, b) });\n"); } #[test] @@ -241,14 +238,12 @@ fn test_call() { } #[test] -#[ignore] fn test_member() { test("x.y[z]", "x.y[z];\n"); test("((x+1).y+1)[z]", "((x + 1).y + 1)[z];\n"); } #[test] -#[ignore] fn test_comma() { test("1, 2, 3", "1, 2, 3;\n"); test("(1, 2), 3", "1, 2, 3;\n"); @@ -261,14 +256,12 @@ fn test_comma() { } #[test] -#[ignore] fn test_unary() { test("+(x--)", "+x--;\n"); test("-(x++)", "-x++;\n"); } #[test] -#[ignore] fn test_nullish() { // "??" can't directly contain "||" or "&&" test("(a && b) ?? c", "(a && b) ?? c;\n"); @@ -284,15 +277,14 @@ fn test_nullish() { } #[test] -#[ignore] fn test_string() { - // test( "let x = ''", "let x = \"\";\n"); - // test( "let x = '\b'", "let x = \"\\b\";\n"); - // test( "let x = '\f'", "let x = \"\\f\";\n"); - // test( "let x = '\t'", "let x = \"\t\";\n"); - // test( "let x = '\v'", "let x = \"\\v\";\n"); - // test( "let x = '\\n'", "let x = \"\\n\";\n"); - // test( "let x = '\\''", "let x = \"'\";\n"); + test("let x = ''", "let x = \"\";\n"); + test("let x = '\\b'", "let x = \"\\b\";\n"); + test("let x = '\\f'", "let x = \"\\f\";\n"); + test("let x = '\t'", "let x = \"\t\";\n"); + test("let x = '\\v'", "let x = \"\\v\";\n"); + test("let x = '\\n'", "let x = \"\\n\";\n"); + test("let x = '\\''", "let x = \"'\";\n"); // test( "let x = '\\\"'", "let x = '\"';\n"); // test( "let x = '\\'\"'", "let x = `'\"`;\n"); // test( "let x = '\\\\'", "let x = \"\\\\\";\n"); @@ -328,16 +320,15 @@ fn test_string() { } #[test] -#[ignore] fn test_template() { test("let x = `\\0`", "let x = `\\0`;\n"); - test("let x = `\\x01`", "let x = `\x01`;\n"); + // test("let x = `\\x01`", "let x = `\x01`;\n"); test("let x = `\\0${0}`", "let x = `\\0${0}`;\n"); - test("let x = `\\x01${0}`", "let x = `\x01${0}`;\n"); + // test("let x = `\\x01${0}`", "let x = `\x01${0}`;\n"); test("let x = `${0}\\0`", "let x = `${0}\\0`;\n"); - test("let x = `${0}\\x01`", "let x = `${0}\x01`;\n"); - test("let x = `${0}\\0${1}`", "let x = `${0}\\0${1}`;\n"); - test("let x = `${0}\\x01${1}`", "let x = `${0}\x01${1}`;\n"); + // test("let x = `${0}\\x01`", "let x = `${0}\x01`;\n"); + // test("let x = `${0}\\0${1}`", "let x = `${0}\\0${1}`;\n"); + // test("let x = `${0}\\x01${1}`", "let x = `${0}\x01${1}`;\n"); test("let x = String.raw`\\1`", "let x = String.raw`\\1`;\n"); test("let x = String.raw`\\x01`", "let x = String.raw`\\x01`;\n"); @@ -352,8 +343,8 @@ fn test_template() { test("let x = `$(y)`", "let x = `$(y)`;\n"); test("let x = `{y}$`", "let x = `{y}$`;\n"); test("let x = `$}y{`", "let x = `$}y{`;\n"); - test("let x = `\\${y}`", "let x = `\\${y}`;\n"); - test("let x = `$\\{y}`", "let x = `\\${y}`;\n"); + // test("let x = `\\${y}`", "let x = `\\${y}`;\n"); + // test("let x = `$\\{y}`", "let x = `\\${y}`;\n"); test("await tag`x`", "await tag`x`;\n"); test("await (tag`x`)", "await tag`x`;\n"); @@ -363,29 +354,28 @@ fn test_template() { test("await (tag`${x}`)", "await tag`${x}`;\n"); test("(await tag)`${x}`", "(await tag)`${x}`;\n"); - test("new tag`x`", "new tag`x`();\n"); - test("new (tag`x`)", "new tag`x`();\n"); - test("new tag()`x`", "new tag()`x`;\n"); - test("(new tag)`x`", "new tag()`x`;\n"); - test_minify("new tag`x`", "new tag`x`;"); - test_minify("new (tag`x`)", "new tag`x`;"); - test_minify("new tag()`x`", "new tag()`x`;"); - test_minify("(new tag)`x`", "new tag()`x`;"); - - test("new tag`${x}`", "new tag`${x}`();\n"); - test("new (tag`${x}`)", "new tag`${x}`();\n"); - test("new tag()`${x}`", "new tag()`${x}`;\n"); - test("(new tag)`${x}`", "new tag()`${x}`;\n"); - test_minify("new tag`${x}`", "new tag`${x}`;"); - test_minify("new (tag`${x}`)", "new tag`${x}`;"); - test_minify("new tag()`${x}`", "new tag()`${x}`;"); - test_minify("(new tag)`${x}`", "new tag()`${x}`;"); + // test("new tag`x`", "new tag`x`();\n"); + // test("new (tag`x`)", "new tag`x`();\n"); + // test("new tag()`x`", "new tag()`x`;\n"); + // test("(new tag)`x`", "new tag()`x`;\n"); + // test_minify("new tag`x`", "new tag`x`;"); + // test_minify("new (tag`x`)", "new tag`x`;"); + // test_minify("new tag()`x`", "new tag()`x`;"); + // test_minify("(new tag)`x`", "new tag()`x`;"); + + // test("new tag`${x}`", "new tag`${x}`();\n"); + // test("new (tag`${x}`)", "new tag`${x}`();\n"); + // test("new tag()`${x}`", "new tag()`${x}`;\n"); + // test("(new tag)`${x}`", "new tag()`${x}`;\n"); + // test_minify("new tag`${x}`", "new tag`${x}`;"); + // test_minify("new (tag`${x}`)", "new tag`${x}`;"); + // test_minify("new tag()`${x}`", "new tag()`${x}`;"); + // test_minify("(new tag)`${x}`", "new tag()`${x}`;"); } #[test] -#[ignore] fn test_object() { - test("let x = {'(':')'}", "let x = { \"(\": \");\" };\n"); + // test("let x = {'(':')'}", "let x = { \"(\": \");\" };\n"); test("({})", "({});\n"); test("({}.x)", "({}).x;\n"); test("({} = {})", "({} = {});\n"); @@ -398,15 +388,15 @@ fn test_object() { // "{ __proto__: __proto__ }" must not become "{ __proto__ }" test( "function foo(__proto__) { return { __proto__: __proto__ } }", - "function foo(__proto__) {\n return { __proto__: __proto__ };\n}\n", + "function foo(__proto__) {\n\treturn { __proto__: __proto__ };\n}\n", ); test( "function foo(__proto__) { return { '__proto__': __proto__ } }", - "function foo(__proto__) {\n return { \"__proto__\": __proto__ };\n}\n", + "function foo(__proto__) {\n\treturn { \"__proto__\": __proto__ };\n}\n", ); test( "function foo(__proto__) { return { ['__proto__']: __proto__ } }", - "function foo(__proto__) {\n return { [\"__proto__\"]: __proto__ };\n}\n", + "function foo(__proto__) {\n\treturn { [\"__proto__\"]: __proto__ };\n}\n", ); test( "import { __proto__ } from 'foo'; let foo = () => ({ __proto__: __proto__ })", @@ -431,44 +421,42 @@ fn test_object() { } #[test] -#[ignore] fn test_for() { // Make sure "in" expressions are forbidden in the right places - test("for ((a in b);;);", "for ((a in b); ; ) ;\n"); - test("for (a ? b : (c in d);;);", "for (a ? b : (c in d); ; ) ;\n"); - test("for ((a ? b : c in d).foo;;);", "for ((a ? b : c in d).foo; ; ) ;\n"); - test("for (var x = (a in b);;);", "for (var x = (a in b); ; ) ;\n"); - test("for (x = (a in b);;);", "for (x = (a in b); ; ) ;\n"); - test("for (x == (a in b);;);", "for (x == (a in b); ; ) ;\n"); - test("for (1 * (x == a in b);;);", "for (1 * (x == a in b); ; ) ;\n"); - test("for (a ? b : x = (c in d);;);", "for (a ? b : x = (c in d); ; ) ;\n"); - test("for (var x = y = (a in b);;);", "for (var x = y = (a in b); ; ) ;\n"); - test("for ([a in b];;);", "for ([a in b]; ; ) ;\n"); - test("for (x(a in b);;);", "for (x(a in b); ; ) ;\n"); - test("for (x[a in b];;);", "for (x[a in b]; ; ) ;\n"); - test("for (x?.[a in b];;);", "for (x?.[a in b]; ; ) ;\n"); - test("for ((x => a in b);;);", "for ((x) => (a in b); ; ) ;\n"); + test("for ((a in b);;);", "for ((a in b);;);\n"); + test("for (a ? b : (c in d);;);", "for (a ? b : (c in d);;);\n"); + test("for ((a ? b : c in d).foo;;);", "for ((a ? b : c in d).foo;;);\n"); + test("for (var x = (a in b);;);", "for (var x = (a in b);;);\n"); + test("for (x = (a in b);;);", "for (x = (a in b);;);\n"); + test("for (x == (a in b);;);", "for (x == (a in b);;);\n"); + test("for (1 * (x == a in b);;);", "for (1 * (x == a in b);;);\n"); + test("for (a ? b : x = (c in d);;);", "for (a ? b : x = (c in d);;);\n"); + test("for (var x = y = (a in b);;);", "for (var x = y = (a in b);;);\n"); + test("for ([a in b];;);", "for ([a in b];;);\n"); + test("for (x(a in b);;);", "for (x(a in b);;);\n"); + test("for (x[a in b];;);", "for (x[a in b];;);\n"); + test("for (x?.[a in b];;);", "for (x?.[a in b];;);\n"); + test("for ((x => a in b);;);", "for ((x) => (a in b);;);\n"); // Make sure for-of loops with commas are wrapped in parentheses - test("for (let a in b, c);", "for (let a in b, c) ;\n"); - test("for (let a of (b, c));", "for (let a of (b, c)) ;\n"); + test("for (let a in b, c);", "for (let a in b, c);\n"); + test("for (let a of (b, c));", "for (let a of (b, c));\n"); } #[test] -#[ignore] fn test_function() { - test("function foo(a = (b, c), ...d) {}", "function foo(a = (b, c), ...d) {\n}\n"); + test("function foo(a = (b, c), ...d) {}", "function foo(a = (b, c), ...d) {}\n"); test( "function foo({[1 + 2]: a = 3} = {[1 + 2]: 3}) {}", - "function foo({ [1 + 2]: a = 3 } = { [1 + 2]: 3 }) {\n}\n", + "function foo({ [1 + 2]: a = 3 } = { [1 + 2]: 3 }) {}\n", ); test( "function foo([a = (1, 2), ...[b, ...c]] = [1, [2, 3]]) {}", - "function foo([a = (1, 2), ...[b, ...c]] = [1, [2, 3]]) {\n}\n", + "function foo([a = (1, 2), ...[b, ...c]] = [1, [2, 3]]) {}\n", ); - test("function foo([] = []) {}", "function foo([] = []) {\n}\n"); - test("function foo([,] = [,]) {}", "function foo([,] = [,]) {\n}\n"); - test("function foo([,,] = [,,]) {}", "function foo([, ,] = [, ,]) {\n}\n"); + test("function foo([] = []) {}", "function foo([] = []) {}\n"); + test("function foo([,] = [,]) {}", "function foo([,] = [,]) {}\n"); + test("function foo([,,] = [,,]) {}", "function foo([, ,] = [, ,]) {}\n"); } #[test] @@ -502,99 +490,94 @@ fn test_comments_and_parentheses() { } #[test] -#[ignore] fn test_pure_comment() { - test("function* foo() {}", "function* foo() {\n}\n"); - test("(function* () {})", "(function* () {\n});\n"); - test("(function* foo() {})", "(function* foo() {\n});\n"); - - test("new (function() {})", "new function() {\n}();\n"); - test("new (function() {})()", "new function() {\n}();\n"); - test("/*@__PURE__*/new (function() {})()", "/* @__PURE__ */ new function() {\n}();\n"); - - test("export default (function() { foo() })", "export default (function() {\n foo();\n});\n"); - test( - "export default (function() { foo() })()", - "export default (function() {\n foo();\n})();\n", - ); - test( - "export default /*@__PURE__*/(function() { foo() })()", - "export default /* @__PURE__ */ (function() {\n foo();\n})();\n", - ); + test("function* foo() {}", "function* foo() {}\n"); + test("(function* () {})", "(function* () {});\n"); + test("(function* foo() {})", "(function* foo() {});\n"); + + test("new (function() {})", "new function() {}();\n"); + test("new (function() {})()", "new function() {}();\n"); + // test("/*@__PURE__*/new (function() {})()", "/* @__PURE__ */ new function() {}();\n"); + + // test("export default (function() { foo() })", "export default (function() {\n foo();\n});\n"); + // test( + // "export default (function() { foo() })()", + // "export default (function() {\n foo();\n})();\n", + // ); + // test( + // "export default /*@__PURE__*/(function() { foo() })()", + // "export default /* @__PURE__ */ (function() {\n foo();\n})();\n", + // ); } #[test] -#[ignore] fn test_generator() { - test("function* foo() {}", "function* foo() {\n}\n"); - test("(function* () {})", "(function* () {\n});\n"); - test("(function* foo() {})", "(function* foo() {\n});\n"); - - test("class Foo { *foo() {} }", "class Foo {\n *foo() {\n }\n}\n"); - test("class Foo { static *foo() {} }", "class Foo {\n static *foo() {\n }\n}\n"); - test("class Foo { *[foo]() {} }", "class Foo {\n *[foo]() {\n }\n}\n"); - test("class Foo { static *[foo]() {} }", "class Foo {\n static *[foo]() {\n }\n}\n"); - - test("(class { *foo() {} })", "(class {\n *foo() {\n }\n});\n"); - test("(class { static *foo() {} })", "(class {\n static *foo() {\n }\n});\n"); - test("(class { *[foo]() {} })", "(class {\n *[foo]() {\n }\n});\n"); - test("(class { static *[foo]() {} })", "(class {\n static *[foo]() {\n }\n});\n"); + test("function* foo() {}", "function* foo() {}\n"); + test("(function* () {})", "(function* () {});\n"); + test("(function* foo() {})", "(function* foo() {});\n"); + + test("class Foo { *foo() {} }", "class Foo {\n\t*foo() {}\n}\n"); + test("class Foo { static *foo() {} }", "class Foo {\n\tstatic *foo() {}\n}\n"); + test("class Foo { *[foo]() {} }", "class Foo {\n\t*[foo]() {}\n}\n"); + test("class Foo { static *[foo]() {} }", "class Foo {\n\tstatic *[foo]() {}\n}\n"); + + test("(class { *foo() {} })", "(class {\n\t*foo() {}\n});\n"); + test("(class { static *foo() {} })", "(class {\n\tstatic *foo() {}\n});\n"); + test("(class { *[foo]() {} })", "(class {\n\t*[foo]() {}\n});\n"); + test("(class { static *[foo]() {} })", "(class {\n\tstatic *[foo]() {}\n});\n"); } #[test] -#[ignore] fn test_arrow() { - test("() => {}", "() => {\n};\n"); + test("() => {}", "() => {};\n"); test("x => (x, 0)", "(x) => (x, 0);\n"); - test("x => {y}", "(x) => {\n y;\n};\n"); - test("(a = (b, c), ...d) => {}", "(a = (b, c), ...d) => {\n};\n"); + test("x => {y}", "(x) => {\n\ty;\n};\n"); + test("(a = (b, c), ...d) => {}", "(a = (b, c), ...d) => {};\n"); test( "({[1 + 2]: a = 3} = {[1 + 2]: 3}) => {}", - "({ [1 + 2]: a = 3 } = { [1 + 2]: 3 }) => {\n};\n", + "({ [1 + 2]: a = 3 } = { [1 + 2]: 3 }) => {};\n", ); test( "([a = (1, 2), ...[b, ...c]] = [1, [2, 3]]) => {}", - "([a = (1, 2), ...[b, ...c]] = [1, [2, 3]]) => {\n};\n", + "([a = (1, 2), ...[b, ...c]] = [1, [2, 3]]) => {};\n", ); - test("([] = []) => {}", "([] = []) => {\n};\n"); - test("([,] = [,]) => {}", "([,] = [,]) => {\n};\n"); - test("([,,] = [,,]) => {}", "([, ,] = [, ,]) => {\n};\n"); - test("a = () => {}", "a = () => {\n};\n"); - test("a || (() => {})", "a || (() => {\n});\n"); - test("({a = b, c = d}) => {}", "({ a = b, c = d }) => {\n};\n"); - test("([{a = b, c = d} = {}] = []) => {}", "([{ a = b, c = d } = {}] = []) => {\n};\n"); - test("({a: [b = c] = []} = {}) => {}", "({ a: [b = c] = [] } = {}) => {\n};\n"); + test("([] = []) => {}", "([] = []) => {};\n"); + test("([,] = [,]) => {}", "([,] = [,]) => {};\n"); + test("([,,] = [,,]) => {}", "([, ,] = [, ,]) => {};\n"); + test("a = () => {}", "a = () => {};\n"); + test("a || (() => {})", "a || (() => {});\n"); + test("({a = b, c = d}) => {}", "({ a = b, c = d }) => {};\n"); + test("([{a = b, c = d} = {}] = []) => {}", "([{ a = b, c = d } = {}] = []) => {};\n"); + test("({a: [b = c] = []} = {}) => {}", "({ a: [b = c] = [] } = {}) => {};\n"); // These are not arrow functions but initially look like one test("(a = b, c)", "a = b, c;\n"); test("([...a = b])", "[...a = b];\n"); test("([...a, ...b])", "[...a, ...b];\n"); - test("({a: b, c() {}})", "({ a: b, c() {\n} });\n"); - test("({a: b, get c() {}})", "({ a: b, get c() {\n} });\n"); - test("({a: b, set c(x) {}})", "({ a: b, set c(x) {\n} });\n"); + test("({a: b, c() {}})", "({\n\ta: b,\n\tc() {}\n});\n"); + test("({a: b, get c() {}})", "({\n\ta: b,\n\tget c() {}\n});\n"); + test("({a: b, set c(x) {}})", "({\n\ta: b,\n\tset c(x) {}\n});\n"); } #[test] -#[ignore] fn test_class() { - test("class Foo extends (a, b) {}", "class Foo extends (a, b) {\n}\n"); - test("class Foo { get foo() {} }", "class Foo {\n get foo() {\n }\n}\n"); - test("class Foo { set foo(x) {} }", "class Foo {\n set foo(x) {\n }\n}\n"); - test("class Foo { static foo() {} }", "class Foo {\n static foo() {\n }\n}\n"); - test("class Foo { static get foo() {} }", "class Foo {\n static get foo() {\n }\n}\n"); - test("class Foo { static set foo(x) {} }", "class Foo {\n static set foo(x) {\n }\n}\n"); + test("class Foo extends (a, b) {}", "class Foo extends (a, b) {}\n"); + test("class Foo { get foo() {} }", "class Foo {\n\tget foo() {}\n}\n"); + test("class Foo { set foo(x) {} }", "class Foo {\n\tset foo(x) {}\n}\n"); + test("class Foo { static foo() {} }", "class Foo {\n\tstatic foo() {}\n}\n"); + test("class Foo { static get foo() {} }", "class Foo {\n\tstatic get foo() {}\n}\n"); + test("class Foo { static set foo(x) {} }", "class Foo {\n\tstatic set foo(x) {}\n}\n"); } #[test] -#[ignore] fn test_auto_accessors() { test( "class Foo { accessor x; static accessor y }", - "class Foo {\n accessor x;\n static accessor y;\n}\n", + "class Foo {\n\taccessor x;\n\tstatic accessor y;\n}\n", ); test( "class Foo { accessor [x]; static accessor [y] }", - "class Foo {\n accessor [x];\n static accessor [y];\n}\n", + "class Foo {\n\taccessor [x];\n\tstatic accessor [y];\n}\n", ); test_minify( "class Foo { accessor x; static accessor y }", @@ -607,16 +590,16 @@ fn test_auto_accessors() { } #[test] -#[ignore] fn test_private_identifiers() { test( "class Foo { #foo; foo() { return #foo in this } }", - "class Foo {\n #foo;\n foo() {\n return #foo in this;\n }\n}\n", - ); - test_minify( - "class Foo { #foo; foo() { return #foo in this } }", - "class Foo{#foo;foo(){return#foo in this}}", + "class Foo {\n\t#foo;\n\tfoo() {\n\t\treturn #foo in this;\n\t}\n}\n", ); + // FIXME + // test_minify( + // "class Foo { #foo; foo() { return #foo in this } }", + // "class Foo{#foo;foo(){return#foo in this}}", + // ); } #[test] @@ -629,83 +612,76 @@ fn test_decorators() { } #[test] -#[ignore] fn test_import() { - test("import('path');", "import(\"path\");;\n"); // The semicolon must not be a separate statement + test("import('path');", "import(\"path\");\n"); // The semicolon must not be a separate statement + // FIXME // Test preservation of Webpack-specific comments - test( - "import(// webpackFoo: 1\n // webpackBar: 2\n 'path');", - "import(\n // webpackFoo: 1\n // webpackBar: 2\n \"path\"\n);\n", - ); - test( "import(// webpackFoo: 1\n // webpackBar: 2\n 'path', {type: 'module'});", "import(\n // webpackFoo: 1\n // webpackBar: 2\n \"path\",\n { type: \"module\" }\n);\n"); - test( - "import(/* webpackFoo: 1 */ /* webpackBar: 2 */ 'path');", - "import(\n /* webpackFoo: 1 */\n /* webpackBar: 2 */\n \"path\"\n);\n", - ); - test( "import(/* webpackFoo: 1 */ /* webpackBar: 2 */ 'path', {type: 'module'});", "import(\n /* webpackFoo: 1 */\n /* webpackBar: 2 */\n \"path\",\n { type: \"module\" }\n);\n"); - test( - "import(\n /* multi\n * line\n * webpackBar: */ 'path');", - "import(\n /* multi\n * line\n * webpackBar: */\n \"path\"\n);\n", - ); - test( - "import(/* webpackFoo: 1 */ 'path' /* webpackBar:2 */);", - "import(\n /* webpackFoo: 1 */\n \"path\"\n /* webpackBar:2 */\n);\n", - ); - test( - "import(/* webpackFoo: 1 */ 'path' /* webpackBar:2 */ ,);", - "import(\n /* webpackFoo: 1 */\n \"path\"\n);\n", - ); // Not currently handled - test( - "import(/* webpackFoo: 1 */ 'path', /* webpackBar:2 */ );", - "import(\n /* webpackFoo: 1 */\n \"path\"\n /* webpackBar:2 */\n);\n", - ); - test( "import(/* webpackFoo: 1 */ 'path', { type: 'module' } /* webpackBar:2 */ );", "import(\n /* webpackFoo: 1 */\n \"path\",\n { type: \"module\" }\n /* webpackBar:2 */\n);\n"); - test( "import(new URL('path', /* webpackFoo: these can go anywhere */ import.meta.url))", - "import(new URL(\n \"path\",\n /* webpackFoo: these can go anywhere */\n import.meta.url\n));\n"); + // test( + // "import(// webpackFoo: 1\n // webpackBar: 2\n 'path');", + // "import(\n // webpackFoo: 1\n // webpackBar: 2\n \"path\"\n);\n", + // ); + // test( "import(// webpackFoo: 1\n // webpackBar: 2\n 'path', {type: 'module'});", "import(\n // webpackFoo: 1\n // webpackBar: 2\n \"path\",\n { type: \"module\" }\n);\n"); + // test( + // "import(/* webpackFoo: 1 */ /* webpackBar: 2 */ 'path');", + // "import(\n /* webpackFoo: 1 */\n /* webpackBar: 2 */\n \"path\"\n);\n", + // ); + // test( "import(/* webpackFoo: 1 */ /* webpackBar: 2 */ 'path', {type: 'module'});", "import(\n /* webpackFoo: 1 */\n /* webpackBar: 2 */\n \"path\",\n { type: \"module\" }\n);\n"); + // test( + // "import(\n /* multi\n * line\n * webpackBar: */ 'path');", + // "import(\n /* multi\n * line\n * webpackBar: */\n \"path\"\n);\n", + // ); + // test( + // "import(/* webpackFoo: 1 */ 'path' /* webpackBar:2 */);", + // "import(\n /* webpackFoo: 1 */\n \"path\"\n /* webpackBar:2 */\n);\n", + // ); + // test( + // "import(/* webpackFoo: 1 */ 'path' /* webpackBar:2 */ ,);", + // "import(\n /* webpackFoo: 1 */\n \"path\"\n);\n", + // ); // Not currently handled + // test( + // "import(/* webpackFoo: 1 */ 'path', /* webpackBar:2 */ );", + // "import(\n /* webpackFoo: 1 */\n \"path\"\n /* webpackBar:2 */\n);\n", + // ); + // test( "import(/* webpackFoo: 1 */ 'path', { type: 'module' } /* webpackBar:2 */ );", "import(\n /* webpackFoo: 1 */\n \"path\",\n { type: \"module\" }\n /* webpackBar:2 */\n);\n"); + // test( "import(new URL('path', /* webpackFoo: these can go anywhere */ import.meta.url))", + // "import(new URL(\n \"path\",\n /* webpackFoo: these can go anywhere */\n import.meta.url\n));\n"); } #[test] -#[ignore] fn test_export_default() { - test("export default function() {}", "export default function() {\n}\n"); - test("export default function foo() {}", "export default function foo() {\n}\n"); - test("export default async function() {}", "export default async function() {\n}\n"); - test("export default async function foo() {}", "export default async function foo() {\n}\n"); - test("export default class {}", "export default class {\n}\n"); - test("export default class foo {}", "export default class foo {\n}\n"); - - test("export default (function() {})", "export default (function() {\n});\n"); - test("export default (function foo() {})", "export default (function foo() {\n});\n"); - test("export default (async function() {})", "export default (async function() {\n});\n"); - test( - "export default (async function foo() {})", - "export default (async function foo() {\n});\n", - ); - test("export default (class {})", "export default (class {\n});\n"); - test("export default (class foo {})", "export default (class foo {\n});\n"); + test("export default function() {}", "export default function() {}\n"); + test("export default function foo() {}", "export default function foo() {}\n"); + test("export default async function() {}", "export default async function() {}\n"); + test("export default async function foo() {}", "export default async function foo() {}\n"); + test("export default class {}", "export default class {}\n"); + test("export default class foo {}", "export default class foo {}\n"); + + test("export default (function() {})", "export default (function() {});\n"); + test("export default (function foo() {})", "export default (function foo() {});\n"); + test("export default (async function() {})", "export default (async function() {});\n"); + test("export default (async function foo() {})", "export default (async function foo() {});\n"); + test("export default (class {})", "export default (class {});\n"); + test("export default (class foo {})", "export default (class foo {});\n"); test( "export default (function() {}.toString())", - "export default (function() {\n}).toString();\n", + "export default (function() {}).toString();\n", ); test( "export default (function foo() {}.toString())", - "export default (function foo() {\n}).toString();\n", + "export default (function foo() {}).toString();\n", ); test( "export default (async function() {}.toString())", - "export default (async function() {\n}).toString();\n", + "export default (async function() {}).toString();\n", ); test( "export default (async function foo() {}.toString())", - "export default (async function foo() {\n}).toString();\n", - ); - test("export default (class {}.toString())", "export default (class {\n}).toString();\n"); - test( - "export default (class foo {}.toString())", - "export default (class foo {\n}).toString();\n", + "export default (async function foo() {}).toString();\n", ); + test("export default (class {}.toString())", "export default (class {}).toString();\n"); + test("export default (class foo {}.toString())", "export default (class foo {}).toString();\n"); test_minify("export default function() {}", "export default function(){}"); test_minify("export default function foo() {}", "export default function foo(){}"); @@ -716,7 +692,6 @@ fn test_export_default() { } #[test] -#[ignore] fn test_whitespace() { test("- -x", "- -x;\n"); test("+ -x", "+-x;\n"); @@ -768,7 +743,7 @@ fn test_whitespace() { test_minify("()=>({})", "()=>({});"); test_minify("()=>({}[1])", "()=>({})[1];"); - test_minify("()=>({}+0)", "()=>\"[object Object]0\";"); + // test_minify("()=>({}+0)", "()=>\"[object Object]0\";"); test_minify("()=>function(){}", "()=>function(){};"); test_minify("(function(){})", "(function(){});"); @@ -855,7 +830,6 @@ fn test_es5() { } #[test] -#[ignore] fn test_ascii_only() { test("let π = 'π'", "let π = \"π\";\n"); test("let π_ = 'π'", "let π_ = \"π\";\n"); @@ -905,96 +879,100 @@ fn test_ascii_only() { // test_minifyASCII(t, "(class 𐀀 extends π {})", "(class \\u{10000} extends \\u03C0{});"); } -// #[test]#[ignore] fn test_jsx() { -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); - -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); - -// testJSX(t, "x", "x;\n"); -// testJSX(t, "x\ny", "x\ny;\n"); -// testJSX(t, "{'x'}{'y'}", "{\"x\"}{\"y\"};\n"); -// testJSX(t, " x", " x;\n"); -// testJSX(t, "x ", "x ;\n"); -// testJSX(t, " ", " ;\n"); -// testJSX(t, "&", "&;\n"); -// testJSX(t, "<", "<;\n"); -// testJSX(t, ">", ">;\n"); -// testJSX(t, "{", "{;\n"); -// testJSX(t, "}", "};\n"); - -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "bd", "bd;\n"); - -// testJSX(t, "<>", "<>;\n"); -// testJSX(t, "<>xz", "<>xz;\n"); - -// // JSX elements as JSX attribute values -// testJSX(t, "/>", " />;\n"); -// testJSX(t, "c/>", "c />;\n"); -// testJSX(t, "{c}/>", "{c} />;\n"); -// testJSX(t, "}/>", "} />;\n"); -// testJSX(t, "c}/>", "c} />;\n"); -// testJSX(t, "{c}}/>", "{c}} />;\n"); - -// // These can't be escaped because JSX lacks a syntax for escapes -// testJSXASCII(t, "<π/>", "<π />;\n"); -// testJSXASCII(t, "<π.𐀀/>", "<π.𐀀 />;\n"); -// testJSXASCII(t, "<𐀀.π/>", "<𐀀.π />;\n"); -// testJSXASCII(t, "<π>x", "<π>x;\n"); -// testJSXASCII(t, "<𐀀>x", "<𐀀>x;\n"); -// testJSXASCII(t, "", ";\n"); -// testJSXASCII(t, "", ";\n"); - -// // JSX text is deliberately not printed as ASCII when JSX preservation is -// // enabled. This is because: -// // -// // a) The JSX specification doesn't say how JSX text is supposed to be interpreted -// // b) Enabling JSX preservation means that JSX will be transformed again anyway -// // c) People do very weird/custom things with JSX that "preserve" shouldn't break -// // -// // See also: https://github.com/evanw/esbuild/issues/3605 -// testJSXASCII(t, "", ";\n"); -// testJSXASCII(t, "", ";\n"); -// testJSXASCII(t, "π", "π;\n"); -// testJSXASCII(t, "𐀀", "𐀀;\n"); - -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, " x y ", " x y ;"); -// testJSXMinify(t, "{' x '}{''}{' y '}", "{\" x \"}{\"\"}{\" y \"};"); -// } +#[test] +#[ignore] +fn test_jsx() { + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + + test("x", "x;\n"); + test("x\ny", "x\ny;\n"); + test("{'x'}{'y'}", "{\"x\"}{\"y\"};\n"); + test(" x", " x;\n"); + test("x ", "x ;\n"); + test(" ", " ;\n"); + test("&", "&;\n"); + test("<", "<;\n"); + test(">", ">;\n"); + test("{", "{;\n"); + test("}", "};\n"); + + test("", ";\n"); + test("", ";\n"); + test("bd", "bd;\n"); + + test("<>", "<>;\n"); + test("<>xz", "<>xz;\n"); + + // JSX elements as JSX attribute values + test("/>", " />;\n"); + test("c/>", "c />;\n"); + test("{c}/>", "{c} />;\n"); + test("}/>", "} />;\n"); + test("c}/>", "c} />;\n"); + test("{c}}/>", "{c}} />;\n"); + + // These can't be escaped because JSX lacks a syntax for escapes + // testJSXASCII(t, "<π/>", "<π />;\n"); + // testJSXASCII(t, "<π.𐀀/>", "<π.𐀀 />;\n"); + // testJSXASCII(t, "<𐀀.π/>", "<𐀀.π />;\n"); + // testJSXASCII(t, "<π>x", "<π>x;\n"); + // testJSXASCII(t, "<𐀀>x", "<𐀀>x;\n"); + // testJSXASCII(t, "", ";\n"); + // testJSXASCII(t, "", ";\n"); + + // JSX text is deliberately not printed as ASCII when JSX preservation is + // enabled. This is because: + // + // a) The JSX specification doesn't say how JSX text is supposed to be interpreted + // b) Enabling JSX preservation means that JSX will be transformed again anyway + // c) People do very weird/custom things with JSX that "preserve" shouldn't break + // + // See also: https://github.com/evanw/esbuild/issues/3605 + // testJSXASCII(t, "", ";\n"); + // testJSXASCII(t, "", ";\n"); + // testJSXASCII(t, "π", "π;\n"); + // testJSXASCII(t, "𐀀", "𐀀;\n"); + + // testJSXMinify(t, "", ";"); + // testJSXMinify(t, "", ";"); + // testJSXMinify(t, " x y ", " x y ;"); + // testJSXMinify(t, "{' x '}{''}{' y '}", "{\" x \"}{\"\"}{\" y \"};"); +} -// #[test]#[ignore] fn TestJSXSingleLine(t *testing.T) { -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); -// testJSX(t, "", ";\n"); - -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, "", ";"); -// testJSXMinify(t, "", ";"); -// } +#[test] +#[ignore] +fn test_jsx_single_line() { + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + test("", ";\n"); + + test_minify("", ";"); + test_minify("", ";"); + test_minify("", ";"); + test_minify("", ";"); + test_minify("", ";"); + test_minify("", ";"); +} #[test] #[ignore] @@ -1038,7 +1016,6 @@ fn test_avoid_slash_script() { } #[test] -#[ignore] fn test_infinity() { test("x = Infinity", "x = Infinity;\n"); test("x = -Infinity", "x = -Infinity;\n"); @@ -1106,7 +1083,6 @@ fn test_binary_operator_visitor() { // See: https://github.com/tc39/proposal-explicit-resource-management #[test] -#[ignore] fn test_using() { test("using x = y", "using x = y;\n"); test("using x = y, z = _", "using x = y, z = _;\n"); diff --git a/crates/oxc_codegen/tests/integration/main.rs b/crates/oxc_codegen/tests/integration/main.rs index 1ef8185ae7e1e..86cc7907378fe 100644 --- a/crates/oxc_codegen/tests/integration/main.rs +++ b/crates/oxc_codegen/tests/integration/main.rs @@ -1,3 +1,4 @@ +#![allow(clippy::missing_panics_doc)] pub mod esbuild; pub mod pure_comments; pub mod tester; diff --git a/crates/oxc_codegen/tests/integration/pure_comments.rs b/crates/oxc_codegen/tests/integration/pure_comments.rs index 6891ddfe9052c..b325981325be0 100644 --- a/crates/oxc_codegen/tests/integration/pure_comments.rs +++ b/crates/oxc_codegen/tests/integration/pure_comments.rs @@ -1,26 +1,8 @@ -use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CommentOptions}; -use oxc_parser::Parser; -use oxc_span::SourceType; - -fn test_comment_helper(source_text: &str, expected: &str) { - let allocator = Allocator::default(); - let source_type = SourceType::default().with_module(true); - let ret = Parser::new(&allocator, source_text, source_type).parse(); - let result = CodeGenerator::new() - .enable_comment( - source_text, - ret.trivias, - CommentOptions { preserve_annotate_comments: true }, - ) - .build(&ret.program) - .source_text; - assert_eq!(expected, result, "for source {source_text}, expect {expected}, got {result}"); -} +use crate::tester::test; #[test] fn annotate_comment() { - test_comment_helper( + test( r" x([ /* #__NO_SIDE_EFFECTS__ */ function() {}, @@ -36,7 +18,7 @@ fn annotate_comment() { ", ); - test_comment_helper( + test( r" x([ /* #__NO_SIDE_EFFECTS__ */ y => y, @@ -49,7 +31,7 @@ fn annotate_comment() { r"x([/* #__NO_SIDE_EFFECTS__ */ (y) => y, /* #__NO_SIDE_EFFECTS__ */ () => {}, /* #__NO_SIDE_EFFECTS__ */ (y) => y, /* #__NO_SIDE_EFFECTS__ */ async (y) => y, /* #__NO_SIDE_EFFECTS__ */ async () => {}, /* #__NO_SIDE_EFFECTS__ */ async (y) => y,]); ", ); - test_comment_helper( + test( r" x([ /* #__NO_SIDE_EFFECTS__ */ y => y, @@ -63,7 +45,7 @@ fn annotate_comment() { ", ); // - test_comment_helper( + test( r" // #__NO_SIDE_EFFECTS__ function a() {} @@ -85,7 +67,7 @@ async function* d() {} ", ); - test_comment_helper( + test( r" // #__NO_SIDE_EFFECTS__ function a() {} @@ -107,7 +89,7 @@ async function* d() {} ", ); - test_comment_helper( + test( r" /* @__NO_SIDE_EFFECTS__ */ export function a() {} /* @__NO_SIDE_EFFECTS__ */ export function* b() {} @@ -120,7 +102,7 @@ async function* d() {} ", ); // Only "c0" and "c2" should have "no side effects" (Rollup only respects "const" and only for the first one) - test_comment_helper( + test( r" /* #__NO_SIDE_EFFECTS__ */ export var v0 = function() {}, v1 = function() {} /* #__NO_SIDE_EFFECTS__ */ export let l0 = function() {}, l1 = function() {} @@ -138,7 +120,7 @@ export const c2 = /* #__NO_SIDE_EFFECTS__ */ () => {}, c3 = () => {}; ", ); // Only "c0" and "c2" should have "no side effects" (Rollup only respects "const" and only for the first one) - test_comment_helper( + test( r" /* #__NO_SIDE_EFFECTS__ */ var v0 = function() {}, v1 = function() {} /* #__NO_SIDE_EFFECTS__ */ let l0 = function() {}, l1 = function() {} @@ -156,7 +138,7 @@ const c2 = /* #__NO_SIDE_EFFECTS__ */ () => {}, c3 = () => {}; ", ); - test_comment_helper( + test( r" isFunction(options) ? // #8326: extend call and options.name access are considered side-effects @@ -165,11 +147,11 @@ isFunction(options) extend({ name: options.name }, extraOptions, { setup: options }))() : options ", - r"isFunction(options) ? /*#__PURE__*/ (() => extend({name: options.name}, extraOptions, {setup: options}))() : options; + r"isFunction(options) ? /*#__PURE__*/ (() => extend({ name: options.name }, extraOptions, { setup: options }))() : options; ", ); - test_comment_helper( + test( r" const obj = { props: /*#__PURE__*/ extend({}, TransitionPropsValidators, { @@ -179,32 +161,27 @@ const obj = { }; const p = /*#__PURE__*/ Promise.resolve(); ", - "const obj = {props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {\n\ttag: String,\n\tmoveClass: String\n})};\nconst p = /*#__PURE__*/ Promise.resolve();\n", + "const obj = { props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {\n\ttag: String,\n\tmoveClass: String\n}) };\nconst p = /*#__PURE__*/ Promise.resolve();\n", ); - test_comment_helper( + test( r" const staticCacheMap = /*#__PURE__*/ new WeakMap() ", "const staticCacheMap = /*#__PURE__*/ new WeakMap();\n", ); - test_comment_helper( - r" + test( + r#" const builtInSymbols = new Set( /*#__PURE__*/ Object.getOwnPropertyNames(Symbol) - .filter(key => key !== 'arguments' && key !== 'caller') -) - -", + .filter(key => key !== "arguments" && key !== "caller") +)"#, "const builtInSymbols = new Set(/*#__PURE__*/ (Object.getOwnPropertyNames(Symbol)).filter((key) => key !== \"arguments\" && key !== \"caller\"));\n", ); - test_comment_helper( - "(/* @__PURE__ */ new Foo()).bar();\n", - "(/* @__PURE__ */ new Foo()).bar();\n", - ); + test("(/* @__PURE__ */ new Foo()).bar();\n", "(/* @__PURE__ */ new Foo()).bar();\n"); - test_comment_helper("(/* @__PURE__ */ Foo()).bar();\n", "(/* @__PURE__ */ Foo()).bar();\n"); + test("(/* @__PURE__ */ Foo()).bar();\n", "(/* @__PURE__ */ Foo()).bar();\n"); } diff --git a/crates/oxc_codegen/tests/integration/tester.rs b/crates/oxc_codegen/tests/integration/tester.rs index 4e309bd1d03f2..77a638e49ba01 100644 --- a/crates/oxc_codegen/tests/integration/tester.rs +++ b/crates/oxc_codegen/tests/integration/tester.rs @@ -1,30 +1,33 @@ use oxc_allocator::Allocator; -use oxc_codegen::{CodeGenerator, CodegenOptions, WhitespaceRemover}; +use oxc_codegen::{CodeGenerator, CommentOptions, WhitespaceRemover}; use oxc_parser::Parser; use oxc_span::SourceType; pub fn test(source_text: &str, expected: &str) { - let source_type = SourceType::default().with_module(true); + let source_type = SourceType::default().with_module(true).with_jsx(true); let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); let result = CodeGenerator::new() - .with_options(CodegenOptions { single_quote: true }) + .enable_comment( + source_text, + ret.trivias, + CommentOptions { preserve_annotate_comments: true }, + ) .build(&ret.program) .source_text; - check(source_text, &result, expected); + assert_eq!( + result, expected, + "\nfor source {source_text:?}\nexpect {expected:?}\ngot {result:?}" + ); } pub fn test_minify(source_text: &str, expected: &str) { - let source_type = SourceType::default().with_module(true); + let source_type = SourceType::default().with_module(true).with_jsx(true); let allocator = Allocator::default(); let ret = Parser::new(&allocator, source_text, source_type).parse(); - let result = WhitespaceRemover::new() - .with_options(CodegenOptions { single_quote: true }) - .build(&ret.program) - .source_text; - check(source_text, &result, expected); -} - -fn check(source_text: &str, result: &str, expected: &str) { - assert_eq!(result, expected, "for source {source_text}, expect {expected}, got {result}"); + let result = WhitespaceRemover::new().build(&ret.program).source_text; + assert_eq!( + result, expected, + "\nfor minify source `{source_text}\nexpect `{expected}\ngot {result:?}" + ); } diff --git a/crates/oxc_codegen/tests/integration/unit.rs b/crates/oxc_codegen/tests/integration/unit.rs index 88e527b597abe..0d3ca122f77e6 100644 --- a/crates/oxc_codegen/tests/integration/unit.rs +++ b/crates/oxc_codegen/tests/integration/unit.rs @@ -1,100 +1,11 @@ use crate::tester::test; -#[test] -fn string() { - test("let x = ''", "let x = '';\n"); - test(r"let x = '\b'", "let x = '\\b';\n"); - test(r"let x = '\f'", "let x = '\\f';\n"); - test("let x = '\t'", "let x = '\t';\n"); - test(r"let x = '\v'", "let x = '\\v';\n"); - test("let x = '\\n'", "let x = '\\n';\n"); - test("let x = '\\''", "let x = '\\'';\n"); - test("let x = '\\\"'", "let x = '\"';\n"); - // test( "let x = '\\'''", "let x = `''`;\n"); - test("let x = '\\\\'", "let x = '\\\\';\n"); - test("let x = '\x00'", "let x = '\\0';\n"); - test("let x = '\x00!'", "let x = '\\0!';\n"); - test("let x = '\x001'", "let x = '\\x001';\n"); - test("let x = '\\0'", "let x = '\\0';\n"); - test("let x = '\\0!'", "let x = '\\0!';\n"); - test("let x = '\x07'", "let x = '\\x07';\n"); - test("let x = '\x07!'", "let x = '\\x07!';\n"); - test("let x = '\x071'", "let x = '\\x071';\n"); - test("let x = '\\7'", "let x = '\\x07';\n"); - test("let x = '\\7!'", "let x = '\\x07!';\n"); - test("let x = '\\01'", "let x = '\x01';\n"); - test("let x = '\x10'", "let x = '\x10';\n"); - test("let x = '\\x10'", "let x = '\x10';\n"); - test("let x = '\x1B'", "let x = '\\x1B';\n"); - test("let x = '\\x1B'", "let x = '\\x1B';\n"); - test("let x = '\\uABCD'", "let x = 'ꯍ';\n"); - // test( "let x = '\\uABCD'", r#"let x = '\uABCD';\n"#); - // test( r#"let x = '\U000123AB'"#, r#"let x = '\U000123AB';\n"#); - // test( "let x = '\\u{123AB}'", r#"let x = '\U000123AB';\n"#); - // test( "let x = '\\uD808\\uDFAB'", r#"let x = '\U000123AB';\n"#); - test("let x = '\\uD808'", "let x = '\\\\ud808';\n"); - test("let x = '\\uD808X'", "let x = '\\\\ud808X';\n"); - test("let x = '\\uDFAB'", "let x = '\\\\udfab';\n"); - test("let x = '\\uDFABX'", "let x = '\\\\udfabX';\n"); - - // test( "let x = '\\x80'", r#"let x = '\U00000080';\n"#); - // test( "let x = '\\xFF'", r#"let x = '\U000000FF';\n"#); - // test( "let x = '\\xF0\\x9F\\x8D\\x95'", r#"let x = '\U000000F0\U0000009F\U0000008D\U00000095';\n"#); - // test("let x = '\\uD801\\uDC02\\uDC03\\uD804'", r#"let x = '\U00010402\\uDC03\\uD804';\n"#) -} - -#[test] -fn template() { - test("let x = `\\0`", "let x = `\\0`;\n"); - test("let x = `\\x01`", "let x = `\\x01`;\n"); - test("let x = `\\0${0}`", "let x = `\\0${0}`;\n"); - // test("let x = `\\x01${0}`", "let x = `\x01${0}`;\n"); - test("let x = `${0}\\0`", "let x = `${0}\\0`;\n"); - // test("let x = `${0}\\x01`", "let x = `${0}\x01`;\n"); - test("let x = `${0}\\0${1}`", "let x = `${0}\\0${1}`;\n"); - // test("let x = `${0}\\x01${1}`", "let x = `${0}\x01${1}`;\n"); - - test("let x = String.raw`\\1`", "let x = String.raw`\\1`;\n"); - test("let x = String.raw`\\x01`", "let x = String.raw`\\x01`;\n"); - test("let x = String.raw`\\1${0}`", "let x = String.raw`\\1${0}`;\n"); - test("let x = String.raw`\\x01${0}`", "let x = String.raw`\\x01${0}`;\n"); - test("let x = String.raw`${0}\\1`", "let x = String.raw`${0}\\1`;\n"); - test("let x = String.raw`${0}\\x01`", "let x = String.raw`${0}\\x01`;\n"); - test("let x = String.raw`${0}\\1${1}`", "let x = String.raw`${0}\\1${1}`;\n"); - test("let x = String.raw`${0}\\x01${1}`", "let x = String.raw`${0}\\x01${1}`;\n"); - - test("let x = `${y}`", "let x = `${y}`;\n"); - test("let x = `$(y)`", "let x = `$(y)`;\n"); - test("let x = `{y}$`", "let x = `{y}$`;\n"); - test("let x = `$}y{`", "let x = `$}y{`;\n"); - test("let x = `\\${y}`", "let x = `\\${y}`;\n"); - // test("let x = `$\\{y}`", "let x = `\\${y}`;\n"); - - // test("await tag`x`", "await tag`x`;\n"); - // test("await (tag`x`)", "await tag`x`;\n"); - // test("(await tag)`x`", "(await tag)`x`;\n"); - - // test("await tag`${x}`", "await tag`${x}`;\n"); - // test("await (tag`${x}`)", "await tag`${x}`;\n"); - // test("(await tag)`${x}`", "(await tag)`${x}`;\n"); - - // test("new tag`x`", "new tag`x`();\n"); - // test("new (tag`x`)", "new tag`x`();\n"); - // test("new tag()`x`", "new tag()`x`;\n"); - // test("(new tag)`x`", "new tag()`x`;\n"); - - // test("new tag`${x}`", "new tag`${x}`();\n"); - // test("new (tag`${x}`)", "new tag`${x}`();\n"); - // test("new tag()`${x}`", "new tag()`${x}`;\n"); - // test("(new tag)`${x}`", "new tag()`${x}`;\n"); -} - #[test] fn module_decl() { - test("export * as foo from 'foo'", "export * as foo from 'foo';\n"); - test("import x from './foo.js' with {}", "import x from './foo.js' with {\n};\n"); - test("import {} from './foo.js' with {}", "import {} from './foo.js' with {\n};\n"); - test("export * from './foo.js' with {}", "export * from './foo.js' with {\n};\n"); + test("export * as foo from 'foo'", "export * as foo from \"foo\";\n"); + test("import x from './foo.js' with {}", "import x from \"./foo.js\" with {\n};\n"); + test("import {} from './foo.js' with {}", "import {} from \"./foo.js\" with {\n};\n"); + test("export * from './foo.js' with {}", "export * from \"./foo.js\" with {\n};\n"); } #[test] @@ -128,16 +39,16 @@ fn for_stmt() { #[test] fn shorthand() { - test("let _ = { x }", "let _ = {x};\n"); + test("let _ = { x }", "let _ = { x };\n"); test("let { x } = y", "let { x } = y;\n"); - test("({ x: (x) })", "({x});\n"); + test("({ x: (x) })", "({ x });\n"); test("({ x } = y)", "({x} = y);\n"); } #[test] fn unicode_escape() { - test("console.log('你好');", "console.log('你好');\n"); - test("console.log('こんにちは');", "console.log('こんにちは');\n"); - test("console.log('안녕하세요');", "console.log('안녕하세요');\n"); - test("console.log('🧑‍🤝‍🧑');", "console.log('🧑‍🤝‍🧑');\n"); + test("console.log('你好');", "console.log(\"你好\");\n"); + test("console.log('こんにちは');", "console.log(\"こんにちは\");\n"); + test("console.log('안녕하세요');", "console.log(\"안녕하세요\");\n"); + test("console.log('🧑‍🤝‍🧑');", "console.log(\"🧑‍🤝‍🧑\");\n"); } diff --git a/crates/oxc_minifier/tests/mangler/snapshots/mangler.snap b/crates/oxc_minifier/tests/mangler/snapshots/mangler.snap index acef0c9a68e02..551e9687ec7cc 100644 --- a/crates/oxc_minifier/tests/mangler/snapshots/mangler.snap +++ b/crates/oxc_minifier/tests/mangler/snapshots/mangler.snap @@ -1,5 +1,5 @@ --- -source: crates/oxc_mangler/tests/integration/main.rs +source: crates/oxc_minifier/tests/mangler/mod.rs --- function foo(a) {a} function a(b) { @@ -8,7 +8,7 @@ function a(b) { function foo(a) { let _ = { x } } function a(b) { - let c = {x}; + let c = { x }; } function foo(a) { let { x } = y } diff --git a/crates/oxc_minifier/tests/oxc/replace_global_defines.rs b/crates/oxc_minifier/tests/oxc/replace_global_defines.rs index 204234f7cd679..6e431583da375 100644 --- a/crates/oxc_minifier/tests/oxc/replace_global_defines.rs +++ b/crates/oxc_minifier/tests/oxc/replace_global_defines.rs @@ -22,5 +22,5 @@ pub(crate) fn test(source_text: &str, expected: &str, config: ReplaceGlobalDefin #[test] fn replace_global_definitions() { let config = ReplaceGlobalDefinesConfig::new(&[("id", "text"), ("str", "'text'")]).unwrap(); - test("id, str", "text,'text'", config); + test("id, str", "text,'text';", config); } diff --git a/crates/oxc_minifier/tests/snapshots/addition_folding.snap b/crates/oxc_minifier/tests/snapshots/addition_folding.snap index be1c5f34f36cd..0197ac1d3ea41 100644 --- a/crates/oxc_minifier/tests/snapshots/addition_folding.snap +++ b/crates/oxc_minifier/tests/snapshots/addition_folding.snap @@ -22,7 +22,6 @@ function foo() { '' + true =================================== MINIFIED =================================== -; 'true'; @@ -30,7 +29,6 @@ function foo() { '' + false =================================== MINIFIED =================================== -; 'false'; @@ -38,7 +36,6 @@ function foo() { '' + null =================================== MINIFIED =================================== -; 'null'; @@ -53,7 +50,6 @@ false + null '1' + '1' =================================== MINIFIED =================================== -; '11'; @@ -68,7 +64,6 @@ NaN + NaN; '' + NaN =================================== MINIFIED =================================== -; 'NaN'; diff --git a/tasks/coverage/codegen_sourcemap.snap b/tasks/coverage/codegen_sourcemap.snap index ab1b06065fd72..e5232d000bfb9 100644 --- a/tasks/coverage/codegen_sourcemap.snap +++ b/tasks/coverage/codegen_sourcemap.snap @@ -157,253 +157,253 @@ Unexpected token (2:0-2:15) "\nexport default" --> (1:0-1:15) "\nexport default" (2:15-2:27) " function ()" --> (1:15-1:26) " function()" (2:27-2:29) " {" --> (1:26-1:27) " " -(2:29-4:0) "}\n" --> (1:27-1:28) "{" -(4:0-4:4) "\nvar" --> (1:28-1:32) "}var" -(4:4-4:8) " a =" --> (1:32-1:36) " a =" -(4:8-5:2) " {\n " --> (1:36-2:1) " {\n" -(5:2-5:7) " fn()" --> (2:1-2:6) "\tfn()" -(5:7-5:9) " {" --> (2:6-2:7) " " -(5:9-6:2) "},\n " --> (2:7-3:1) "{},\n" -(6:2-6:5) " fn" --> (3:1-3:5) "\tfn:" -(6:5-6:16) ":function()" --> (3:5-3:16) " function()" -(6:16-6:18) " {" --> (3:16-3:17) " " -(6:18-7:2) "},\n " --> (3:17-4:1) "{},\n" -(7:2-7:3) " " --> (4:1-4:2) "\t" -(7:3-7:7) "[fn]" --> (4:2-4:7) "[fn]:" -(7:7-7:18) ":function()" --> (4:7-4:18) " function()" -(7:18-7:20) " {" --> (4:18-4:19) " " -(7:20-8:2) "},\n " --> (4:19-5:1) "{},\n" -(8:2-8:3) " " --> (5:1-5:2) "\t" -(8:3-8:9) "[\"fn\"]" --> (5:2-5:9) "[\"fn\"]:" -(8:9-8:20) ":function()" --> (5:9-5:20) " function()" -(8:20-8:22) " {" --> (5:20-5:21) " " -(8:22-9:2) "},\n " --> (5:21-6:1) "{},\n" -(9:2-9:3) " " --> (6:1-6:2) "\t" -(9:3-9:14) "[function()" --> (6:2-6:13) "[function()" -(9:14-9:16) " {" --> (6:13-6:14) " " -(9:16-9:18) "}]" --> (6:14-6:18) "{}]:" -(9:18-9:29) ":function()" --> (6:18-6:29) " function()" -(9:29-9:31) " {" --> (6:29-6:30) " " -(9:31-10:2) "},\n " --> (6:30-7:1) "{},\n" -(10:2-10:3) " " --> (7:1-7:2) "\t" -(10:3-10:8) "[()=>" --> (7:2-7:8) "[() =>" -(10:8-10:10) " {" --> (7:8-7:9) " " -(10:10-10:12) "}]" --> (7:9-7:13) "{}]:" -(10:12-10:23) ":function()" --> (7:13-7:24) " function()" -(10:23-10:25) " {" --> (7:24-7:25) " " -(10:25-11:2) "},\n " --> (7:25-8:1) "{},\n" -(11:2-11:3) " " --> (8:1-8:2) "\t" -(11:3-11:9) "[fn]()" --> (8:2-8:8) "[fn]()" -(11:9-11:12) " { " --> (8:8-8:9) " " -(11:12-12:2) "},\n " --> (8:9-9:1) "{},\n" -(12:2-12:3) " " --> (9:1-9:2) "\t" -(12:3-12:11) "[\"fn\"]()" --> (9:2-9:10) "[\"fn\"]()" -(12:11-12:14) " { " --> (9:10-9:11) " " -(12:14-13:2) "},\n " --> (9:11-10:1) "{},\n" -(13:2-13:3) " " --> (10:1-10:2) "\t" -(13:3-13:14) "[function()" --> (10:2-10:13) "[function()" -(13:14-13:16) " {" --> (10:13-10:14) " " -(13:16-13:20) "}]()" --> (10:14-10:19) "{}]()" -(13:20-13:23) " { " --> (10:19-10:20) " " -(13:23-14:2) "},\n " --> (10:20-11:1) "{},\n" -(14:2-14:3) " " --> (11:1-11:2) "\t" -(14:3-14:8) "[()=>" --> (11:2-11:8) "[() =>" -(14:8-14:10) " {" --> (11:8-11:9) " " -(14:10-14:14) "}]()" --> (11:9-11:14) "{}]()" -(14:14-14:17) " { " --> (11:14-11:15) " " -(14:17-15:1) "}\n" --> (11:15-12:0) "{}" -(15:1-17:0) "}\n" --> (12:0-13:0) "\n};" -(17:0-17:6) "\nclass" --> (13:0-13:6) "\nclass" -(17:6-17:8) " b" --> (13:6-13:8) " b" -(17:8-18:2) " {\n " --> (13:8-14:1) " {\n" -(18:2-18:7) " fn()" --> (14:1-14:6) "\tfn()" -(18:7-18:9) " {" --> (14:6-14:7) " " -(18:9-19:2) "};\n " --> (14:7-15:1) "{}\n" -(19:2-19:5) " fn" --> (15:1-15:6) "\tfn =" -(19:5-19:16) "=function()" --> (15:6-15:17) " function()" -(19:16-19:18) " {" --> (15:17-15:18) " " -(19:18-20:2) "};\n " --> (15:18-16:1) "{};\n" -(20:2-20:3) " " --> (16:1-16:2) "\t" -(20:3-20:7) "[fn]" --> (16:2-16:8) "[fn] =" -(20:7-20:18) "=function()" --> (16:8-16:19) " function()" -(20:18-20:20) " {" --> (16:19-16:20) " " -(20:20-21:2) "};\n " --> (16:20-17:1) "{};\n" -(21:2-21:3) " " --> (17:1-17:2) "\t" -(21:3-21:9) "[\"fn\"]" --> (17:2-17:10) "[\"fn\"] =" -(21:9-21:20) "=function()" --> (17:10-17:21) " function()" -(21:20-21:22) " {" --> (17:21-17:22) " " -(21:22-22:2) "};\n " --> (17:22-18:1) "{};\n" -(22:2-22:3) " " --> (18:1-18:2) "\t" -(22:3-22:14) "[function()" --> (18:2-18:13) "[function()" -(22:14-22:16) " {" --> (18:13-18:14) " " -(22:16-22:18) "}]" --> (18:14-18:19) "{}] =" -(22:18-22:29) "=function()" --> (18:19-18:30) " function()" -(22:29-22:31) " {" --> (18:30-18:31) " " -(22:31-23:2) "};\n " --> (18:31-19:1) "{};\n" -(23:2-23:3) " " --> (19:1-19:2) "\t" -(23:3-23:8) "[()=>" --> (19:2-19:8) "[() =>" -(23:8-23:10) " {" --> (19:8-19:9) " " -(23:10-23:12) "}]" --> (19:9-19:14) "{}] =" -(23:12-23:23) "=function()" --> (19:14-19:25) " function()" -(23:23-23:25) " {" --> (19:25-19:26) " " -(23:25-24:2) "};\n " --> (19:26-20:1) "{};\n" -(24:2-24:3) " " --> (20:1-20:2) "\t" -(24:3-24:9) "[fn]()" --> (20:2-20:8) "[fn]()" -(24:9-24:12) " { " --> (20:8-20:9) " " -(24:12-25:2) "};\n " --> (20:9-21:1) "{}\n" -(25:2-25:3) " " --> (21:1-21:2) "\t" -(25:3-25:11) "[\"fn\"]()" --> (21:2-21:10) "[\"fn\"]()" -(25:11-25:14) " { " --> (21:10-21:11) " " -(25:14-26:2) "};\n " --> (21:11-22:1) "{}\n" -(26:2-26:3) " " --> (22:1-22:2) "\t" -(26:3-26:14) "[function()" --> (22:2-22:13) "[function()" -(26:14-26:16) " {" --> (22:13-22:14) " " -(26:16-26:20) "}]()" --> (22:14-22:19) "{}]()" -(26:20-26:23) " { " --> (22:19-22:20) " " -(26:23-27:2) "};\n " --> (22:20-23:1) "{}\n" -(27:2-27:3) " " --> (23:1-23:2) "\t" -(27:3-27:8) "[()=>" --> (23:2-23:8) "[() =>" -(27:8-27:10) " {" --> (23:8-23:9) " " -(27:10-27:14) "}]()" --> (23:9-23:14) "{}]()" -(27:14-27:17) " { " --> (23:14-23:15) " " -(27:17-28:2) "};\n " --> (23:15-24:1) "{}\n" -(28:2-28:7) " #x =" --> (24:1-24:6) "\t#x =" -(28:7-28:18) " function()" --> (24:6-24:17) " function()" -(28:18-28:20) " {" --> (24:17-24:18) " " -(28:20-29:2) "};\n " --> (24:18-25:1) "{};\n" -(29:2-29:11) " accessor" --> (25:1-25:10) "\taccessor" -(29:11-29:15) " y =" --> (25:10-25:12) " y" -(29:15-29:26) " function()" --> (25:12-25:23) "=function()" -(29:26-29:28) " {" --> (25:23-25:24) " " -(29:28-30:1) "}\n" --> (25:24-26:0) "{};" -(30:1-32:0) "}\n" --> (26:0-27:0) "\n}" -(32:0-32:4) "\nvar" --> (27:0-27:4) "\nvar" -(32:4-32:9) " aa =" --> (27:4-27:9) " aa =" -(32:9-33:2) " {\n " --> (27:9-28:1) " {\n" -(33:2-33:5) " fn" --> (28:1-28:5) "\tfn:" -(33:5-33:14) ":function" --> (28:5-28:14) " function" -(33:14-33:18) " a()" --> (28:14-28:18) " a()" -(33:18-33:20) " {" --> (28:18-28:19) " " -(33:20-34:2) "},\n " --> (28:19-29:1) "{},\n" -(34:2-34:3) " " --> (29:1-29:2) "\t" -(34:3-34:7) "[fn]" --> (29:2-29:7) "[fn]:" -(34:7-34:16) ":function" --> (29:7-29:16) " function" -(34:16-34:20) " a()" --> (29:16-29:20) " a()" -(34:20-34:22) " {" --> (29:20-29:21) " " -(34:22-35:2) "},\n " --> (29:21-30:1) "{},\n" -(35:2-35:3) " " --> (30:1-30:2) "\t" -(35:3-35:9) "[\"fn\"]" --> (30:2-30:9) "[\"fn\"]:" -(35:9-35:18) ":function" --> (30:9-30:18) " function" -(35:18-35:22) " a()" --> (30:18-30:22) " a()" -(35:22-35:24) " {" --> (30:22-30:23) " " -(35:24-36:2) "},\n " --> (30:23-31:1) "{},\n" -(36:2-36:3) " " --> (31:1-31:2) "\t" -(36:3-36:14) "[function()" --> (31:2-31:13) "[function()" -(36:14-36:16) " {" --> (31:13-31:14) " " -(36:16-36:18) "}]" --> (31:14-31:18) "{}]:" -(36:18-36:27) ":function" --> (31:18-31:27) " function" -(36:27-36:31) " a()" --> (31:27-31:31) " a()" -(36:31-36:33) " {" --> (31:31-31:32) " " -(36:33-37:2) "},\n " --> (31:32-32:1) "{},\n" -(37:2-37:3) " " --> (32:1-32:2) "\t" -(37:3-37:8) "[()=>" --> (32:2-32:8) "[() =>" -(37:8-37:10) " {" --> (32:8-32:9) " " -(37:10-37:12) "}]" --> (32:9-32:13) "{}]:" -(37:12-37:21) ":function" --> (32:13-32:22) " function" -(37:21-37:25) " a()" --> (32:22-32:26) " a()" -(37:25-37:27) " {" --> (32:26-32:27) " " -(37:27-38:1) "},\n" --> (32:27-33:0) "{}" -(38:1-40:0) "}\n" --> (33:0-34:0) "\n};" -(40:0-40:6) "\nclass" --> (34:0-34:6) "\nclass" -(40:6-40:9) " bb" --> (34:6-34:9) " bb" -(40:9-41:2) " {\n " --> (34:9-35:1) " {\n" -(41:2-41:5) " fn" --> (35:1-35:6) "\tfn =" -(41:5-41:14) "=function" --> (35:6-35:15) " function" -(41:14-41:18) " a()" --> (35:15-35:19) " a()" -(41:18-41:20) " {" --> (35:19-35:20) " " -(41:20-42:2) "};\n " --> (35:20-36:1) "{};\n" -(42:2-42:3) " " --> (36:1-36:2) "\t" -(42:3-42:7) "[fn]" --> (36:2-36:8) "[fn] =" -(42:7-42:16) "=function" --> (36:8-36:17) " function" -(42:16-42:20) " a()" --> (36:17-36:21) " a()" -(42:20-42:22) " {" --> (36:21-36:22) " " -(42:22-43:2) "};\n " --> (36:22-37:1) "{};\n" -(43:2-43:3) " " --> (37:1-37:2) "\t" -(43:3-43:9) "[\"fn\"]" --> (37:2-37:10) "[\"fn\"] =" -(43:9-43:18) "=function" --> (37:10-37:19) " function" -(43:18-43:22) " a()" --> (37:19-37:23) " a()" -(43:22-43:24) " {" --> (37:23-37:24) " " -(43:24-44:2) "};\n " --> (37:24-38:1) "{};\n" -(44:2-44:3) " " --> (38:1-38:2) "\t" -(44:3-44:14) "[function()" --> (38:2-38:13) "[function()" -(44:14-44:16) " {" --> (38:13-38:14) " " -(44:16-44:18) "}]" --> (38:14-38:19) "{}] =" -(44:18-44:27) "=function" --> (38:19-38:28) " function" -(44:27-44:31) " a()" --> (38:28-38:32) " a()" -(44:31-44:33) " {" --> (38:32-38:33) " " -(44:33-45:2) "};\n " --> (38:33-39:1) "{};\n" -(45:2-45:3) " " --> (39:1-39:2) "\t" -(45:3-45:8) "[()=>" --> (39:2-39:8) "[() =>" -(45:8-45:10) " {" --> (39:8-39:9) " " -(45:10-45:12) "}]" --> (39:9-39:14) "{}] =" -(45:12-45:21) "=function" --> (39:14-39:23) " function" -(45:21-45:25) " a()" --> (39:23-39:27) " a()" -(45:25-45:27) " {" --> (39:27-39:28) " " -(45:27-46:1) "};\n" --> (39:28-40:0) "{};" -(46:1-48:0) "}\n" --> (40:0-41:0) "\n}" -(48:0-48:4) "\nvar" --> (41:0-41:4) "\nvar" -(48:4-48:8) " x =" --> (41:4-41:8) " x =" -(48:8-48:17) " function" --> (41:8-41:17) " function" -(48:17-48:22) " fn()" --> (41:17-41:22) " fn()" -(48:22-48:24) " {" --> (41:22-41:23) " " -(48:24-49:0) "};" --> (41:23-42:0) "{};" -(49:0-49:4) "\nvar" --> (42:0-42:4) "\nvar" -(49:4-49:8) " x =" --> (42:4-42:8) " x =" -(49:8-49:20) " function ()" --> (42:8-42:19) " function()" -(49:20-49:22) " {" --> (42:19-42:20) " " -(49:22-51:0) "};\n" --> (42:20-43:0) "{};" -(51:0-51:1) "\n" --> (43:0-43:0) "" -(51:1-51:10) "(function" --> (43:0-43:10) "\n(function" -(51:10-51:15) " fn()" --> (43:10-43:15) " fn()" -(51:15-51:17) " {" --> (43:15-43:16) " " -(51:17-53:0) "});\n" --> (43:16-44:0) "{});" -(53:0-53:4) "\nvar" --> (44:0-44:4) "\nvar" -(53:4-53:8) " z =" --> (44:4-44:8) " z =" -(53:8-53:14) " () =>" --> (44:8-44:14) " () =>" -(53:14-53:16) " {" --> (44:14-44:15) " " -(53:16-54:0) "};" --> (44:15-45:0) "{};" -(54:0-54:4) "\nvar" --> (45:0-45:4) "\nvar" -(54:4-54:8) " z =" --> (45:4-45:8) " z =" -(54:8-54:13) " x =>" --> (45:8-45:15) " (x) =>" -(54:13-54:15) " {" --> (45:15-45:16) " " -(54:15-55:0) "};" --> (45:16-46:0) "{};" -(55:0-55:4) "\nvar" --> (46:0-46:4) "\nvar" -(55:4-55:8) " z =" --> (46:4-46:8) " z =" -(55:8-55:9) " " --> (46:8-46:9) " " -(55:9-55:15) "(x) =>" --> (46:9-46:15) "(x) =>" -(55:15-55:17) " {" --> (46:15-46:16) " " -(55:17-56:0) "};" --> (46:16-47:0) "{};" -(56:0-56:4) "\nvar" --> (47:0-47:4) "\nvar" -(56:4-56:8) " z =" --> (47:4-47:8) " z =" -(56:8-56:9) " " --> (47:8-47:9) " " -(56:9-56:12) "(x," --> (47:9-47:12) "(x," -(56:12-56:15) " y," --> (47:12-47:15) " y," -(56:15-56:21) " z) =>" --> (47:15-47:21) " z) =>" -(56:21-56:23) " {" --> (47:21-47:22) " " -(56:23-58:0) "};\n" --> (47:22-48:0) "{};" -(58:0-58:4) "\nx =" --> (48:0-48:4) "\nx =" -(58:4-58:15) " function()" --> (48:4-48:15) " function()" -(58:15-58:17) " {" --> (48:15-48:16) " " -(58:17-60:0) "};\n" --> (48:16-49:0) "{};" -(60:0-60:2) "\n(" --> (49:0-49:1) "\n" -(60:2-60:4) " {" --> (49:1-49:2) "(" -(60:4-60:8) " x =" --> (49:2-49:6) "{x =" -(60:8-60:19) " function()" --> (49:6-49:17) " function()" -(60:19-60:21) " {" --> (49:17-49:18) " " -(60:21-60:23) "} " --> (49:18-49:20) "{}" -(60:23-60:26) "} =" --> (49:20-49:23) "} =" -(60:26-60:28) " {" --> (49:23-49:24) " " -(60:28-61:1) "});\n" --> (49:24-50:1) "{});\n" +(2:29-4:0) "}\n" --> (1:27-2:0) "{}" +(4:0-4:4) "\nvar" --> (2:0-2:4) "\nvar" +(4:4-4:8) " a =" --> (2:4-2:8) " a =" +(4:8-5:2) " {\n " --> (2:8-3:1) " {\n" +(5:2-5:7) " fn()" --> (3:1-3:6) "\tfn()" +(5:7-5:9) " {" --> (3:6-3:7) " " +(5:9-6:2) "},\n " --> (3:7-4:1) "{},\n" +(6:2-6:5) " fn" --> (4:1-4:5) "\tfn:" +(6:5-6:16) ":function()" --> (4:5-4:16) " function()" +(6:16-6:18) " {" --> (4:16-4:17) " " +(6:18-7:2) "},\n " --> (4:17-5:1) "{},\n" +(7:2-7:3) " " --> (5:1-5:2) "\t" +(7:3-7:7) "[fn]" --> (5:2-5:7) "[fn]:" +(7:7-7:18) ":function()" --> (5:7-5:18) " function()" +(7:18-7:20) " {" --> (5:18-5:19) " " +(7:20-8:2) "},\n " --> (5:19-6:1) "{},\n" +(8:2-8:3) " " --> (6:1-6:2) "\t" +(8:3-8:9) "[\"fn\"]" --> (6:2-6:9) "[\"fn\"]:" +(8:9-8:20) ":function()" --> (6:9-6:20) " function()" +(8:20-8:22) " {" --> (6:20-6:21) " " +(8:22-9:2) "},\n " --> (6:21-7:1) "{},\n" +(9:2-9:3) " " --> (7:1-7:2) "\t" +(9:3-9:14) "[function()" --> (7:2-7:13) "[function()" +(9:14-9:16) " {" --> (7:13-7:14) " " +(9:16-9:18) "}]" --> (7:14-7:18) "{}]:" +(9:18-9:29) ":function()" --> (7:18-7:29) " function()" +(9:29-9:31) " {" --> (7:29-7:30) " " +(9:31-10:2) "},\n " --> (7:30-8:1) "{},\n" +(10:2-10:3) " " --> (8:1-8:2) "\t" +(10:3-10:8) "[()=>" --> (8:2-8:8) "[() =>" +(10:8-10:10) " {" --> (8:8-8:9) " " +(10:10-10:12) "}]" --> (8:9-8:13) "{}]:" +(10:12-10:23) ":function()" --> (8:13-8:24) " function()" +(10:23-10:25) " {" --> (8:24-8:25) " " +(10:25-11:2) "},\n " --> (8:25-9:1) "{},\n" +(11:2-11:3) " " --> (9:1-9:2) "\t" +(11:3-11:9) "[fn]()" --> (9:2-9:8) "[fn]()" +(11:9-11:12) " { " --> (9:8-9:9) " " +(11:12-12:2) "},\n " --> (9:9-10:1) "{},\n" +(12:2-12:3) " " --> (10:1-10:2) "\t" +(12:3-12:11) "[\"fn\"]()" --> (10:2-10:10) "[\"fn\"]()" +(12:11-12:14) " { " --> (10:10-10:11) " " +(12:14-13:2) "},\n " --> (10:11-11:1) "{},\n" +(13:2-13:3) " " --> (11:1-11:2) "\t" +(13:3-13:14) "[function()" --> (11:2-11:13) "[function()" +(13:14-13:16) " {" --> (11:13-11:14) " " +(13:16-13:20) "}]()" --> (11:14-11:19) "{}]()" +(13:20-13:23) " { " --> (11:19-11:20) " " +(13:23-14:2) "},\n " --> (11:20-12:1) "{},\n" +(14:2-14:3) " " --> (12:1-12:2) "\t" +(14:3-14:8) "[()=>" --> (12:2-12:8) "[() =>" +(14:8-14:10) " {" --> (12:8-12:9) " " +(14:10-14:14) "}]()" --> (12:9-12:14) "{}]()" +(14:14-14:17) " { " --> (12:14-12:15) " " +(14:17-15:1) "}\n" --> (12:15-13:0) "{}" +(15:1-17:0) "}\n" --> (13:0-14:0) "\n};" +(17:0-17:6) "\nclass" --> (14:0-14:6) "\nclass" +(17:6-17:8) " b" --> (14:6-14:8) " b" +(17:8-18:2) " {\n " --> (14:8-15:1) " {\n" +(18:2-18:7) " fn()" --> (15:1-15:6) "\tfn()" +(18:7-18:9) " {" --> (15:6-15:7) " " +(18:9-19:2) "};\n " --> (15:7-16:1) "{}\n" +(19:2-19:5) " fn" --> (16:1-16:6) "\tfn =" +(19:5-19:16) "=function()" --> (16:6-16:17) " function()" +(19:16-19:18) " {" --> (16:17-16:18) " " +(19:18-20:2) "};\n " --> (16:18-17:1) "{};\n" +(20:2-20:3) " " --> (17:1-17:2) "\t" +(20:3-20:7) "[fn]" --> (17:2-17:8) "[fn] =" +(20:7-20:18) "=function()" --> (17:8-17:19) " function()" +(20:18-20:20) " {" --> (17:19-17:20) " " +(20:20-21:2) "};\n " --> (17:20-18:1) "{};\n" +(21:2-21:3) " " --> (18:1-18:2) "\t" +(21:3-21:9) "[\"fn\"]" --> (18:2-18:10) "[\"fn\"] =" +(21:9-21:20) "=function()" --> (18:10-18:21) " function()" +(21:20-21:22) " {" --> (18:21-18:22) " " +(21:22-22:2) "};\n " --> (18:22-19:1) "{};\n" +(22:2-22:3) " " --> (19:1-19:2) "\t" +(22:3-22:14) "[function()" --> (19:2-19:13) "[function()" +(22:14-22:16) " {" --> (19:13-19:14) " " +(22:16-22:18) "}]" --> (19:14-19:19) "{}] =" +(22:18-22:29) "=function()" --> (19:19-19:30) " function()" +(22:29-22:31) " {" --> (19:30-19:31) " " +(22:31-23:2) "};\n " --> (19:31-20:1) "{};\n" +(23:2-23:3) " " --> (20:1-20:2) "\t" +(23:3-23:8) "[()=>" --> (20:2-20:8) "[() =>" +(23:8-23:10) " {" --> (20:8-20:9) " " +(23:10-23:12) "}]" --> (20:9-20:14) "{}] =" +(23:12-23:23) "=function()" --> (20:14-20:25) " function()" +(23:23-23:25) " {" --> (20:25-20:26) " " +(23:25-24:2) "};\n " --> (20:26-21:1) "{};\n" +(24:2-24:3) " " --> (21:1-21:2) "\t" +(24:3-24:9) "[fn]()" --> (21:2-21:8) "[fn]()" +(24:9-24:12) " { " --> (21:8-21:9) " " +(24:12-25:2) "};\n " --> (21:9-22:1) "{}\n" +(25:2-25:3) " " --> (22:1-22:2) "\t" +(25:3-25:11) "[\"fn\"]()" --> (22:2-22:10) "[\"fn\"]()" +(25:11-25:14) " { " --> (22:10-22:11) " " +(25:14-26:2) "};\n " --> (22:11-23:1) "{}\n" +(26:2-26:3) " " --> (23:1-23:2) "\t" +(26:3-26:14) "[function()" --> (23:2-23:13) "[function()" +(26:14-26:16) " {" --> (23:13-23:14) " " +(26:16-26:20) "}]()" --> (23:14-23:19) "{}]()" +(26:20-26:23) " { " --> (23:19-23:20) " " +(26:23-27:2) "};\n " --> (23:20-24:1) "{}\n" +(27:2-27:3) " " --> (24:1-24:2) "\t" +(27:3-27:8) "[()=>" --> (24:2-24:8) "[() =>" +(27:8-27:10) " {" --> (24:8-24:9) " " +(27:10-27:14) "}]()" --> (24:9-24:14) "{}]()" +(27:14-27:17) " { " --> (24:14-24:15) " " +(27:17-28:2) "};\n " --> (24:15-25:1) "{}\n" +(28:2-28:7) " #x =" --> (25:1-25:6) "\t#x =" +(28:7-28:18) " function()" --> (25:6-25:17) " function()" +(28:18-28:20) " {" --> (25:17-25:18) " " +(28:20-29:2) "};\n " --> (25:18-26:1) "{};\n" +(29:2-29:11) " accessor" --> (26:1-26:10) "\taccessor" +(29:11-29:15) " y =" --> (26:10-26:12) " y" +(29:15-29:26) " function()" --> (26:12-26:23) "=function()" +(29:26-29:28) " {" --> (26:23-26:24) " " +(29:28-30:1) "}\n" --> (26:24-27:0) "{};" +(30:1-32:0) "}\n" --> (27:0-28:0) "\n}" +(32:0-32:4) "\nvar" --> (28:0-28:4) "\nvar" +(32:4-32:9) " aa =" --> (28:4-28:9) " aa =" +(32:9-33:2) " {\n " --> (28:9-29:1) " {\n" +(33:2-33:5) " fn" --> (29:1-29:5) "\tfn:" +(33:5-33:14) ":function" --> (29:5-29:14) " function" +(33:14-33:18) " a()" --> (29:14-29:18) " a()" +(33:18-33:20) " {" --> (29:18-29:19) " " +(33:20-34:2) "},\n " --> (29:19-30:1) "{},\n" +(34:2-34:3) " " --> (30:1-30:2) "\t" +(34:3-34:7) "[fn]" --> (30:2-30:7) "[fn]:" +(34:7-34:16) ":function" --> (30:7-30:16) " function" +(34:16-34:20) " a()" --> (30:16-30:20) " a()" +(34:20-34:22) " {" --> (30:20-30:21) " " +(34:22-35:2) "},\n " --> (30:21-31:1) "{},\n" +(35:2-35:3) " " --> (31:1-31:2) "\t" +(35:3-35:9) "[\"fn\"]" --> (31:2-31:9) "[\"fn\"]:" +(35:9-35:18) ":function" --> (31:9-31:18) " function" +(35:18-35:22) " a()" --> (31:18-31:22) " a()" +(35:22-35:24) " {" --> (31:22-31:23) " " +(35:24-36:2) "},\n " --> (31:23-32:1) "{},\n" +(36:2-36:3) " " --> (32:1-32:2) "\t" +(36:3-36:14) "[function()" --> (32:2-32:13) "[function()" +(36:14-36:16) " {" --> (32:13-32:14) " " +(36:16-36:18) "}]" --> (32:14-32:18) "{}]:" +(36:18-36:27) ":function" --> (32:18-32:27) " function" +(36:27-36:31) " a()" --> (32:27-32:31) " a()" +(36:31-36:33) " {" --> (32:31-32:32) " " +(36:33-37:2) "},\n " --> (32:32-33:1) "{},\n" +(37:2-37:3) " " --> (33:1-33:2) "\t" +(37:3-37:8) "[()=>" --> (33:2-33:8) "[() =>" +(37:8-37:10) " {" --> (33:8-33:9) " " +(37:10-37:12) "}]" --> (33:9-33:13) "{}]:" +(37:12-37:21) ":function" --> (33:13-33:22) " function" +(37:21-37:25) " a()" --> (33:22-33:26) " a()" +(37:25-37:27) " {" --> (33:26-33:27) " " +(37:27-38:1) "},\n" --> (33:27-34:0) "{}" +(38:1-40:0) "}\n" --> (34:0-35:0) "\n};" +(40:0-40:6) "\nclass" --> (35:0-35:6) "\nclass" +(40:6-40:9) " bb" --> (35:6-35:9) " bb" +(40:9-41:2) " {\n " --> (35:9-36:1) " {\n" +(41:2-41:5) " fn" --> (36:1-36:6) "\tfn =" +(41:5-41:14) "=function" --> (36:6-36:15) " function" +(41:14-41:18) " a()" --> (36:15-36:19) " a()" +(41:18-41:20) " {" --> (36:19-36:20) " " +(41:20-42:2) "};\n " --> (36:20-37:1) "{};\n" +(42:2-42:3) " " --> (37:1-37:2) "\t" +(42:3-42:7) "[fn]" --> (37:2-37:8) "[fn] =" +(42:7-42:16) "=function" --> (37:8-37:17) " function" +(42:16-42:20) " a()" --> (37:17-37:21) " a()" +(42:20-42:22) " {" --> (37:21-37:22) " " +(42:22-43:2) "};\n " --> (37:22-38:1) "{};\n" +(43:2-43:3) " " --> (38:1-38:2) "\t" +(43:3-43:9) "[\"fn\"]" --> (38:2-38:10) "[\"fn\"] =" +(43:9-43:18) "=function" --> (38:10-38:19) " function" +(43:18-43:22) " a()" --> (38:19-38:23) " a()" +(43:22-43:24) " {" --> (38:23-38:24) " " +(43:24-44:2) "};\n " --> (38:24-39:1) "{};\n" +(44:2-44:3) " " --> (39:1-39:2) "\t" +(44:3-44:14) "[function()" --> (39:2-39:13) "[function()" +(44:14-44:16) " {" --> (39:13-39:14) " " +(44:16-44:18) "}]" --> (39:14-39:19) "{}] =" +(44:18-44:27) "=function" --> (39:19-39:28) " function" +(44:27-44:31) " a()" --> (39:28-39:32) " a()" +(44:31-44:33) " {" --> (39:32-39:33) " " +(44:33-45:2) "};\n " --> (39:33-40:1) "{};\n" +(45:2-45:3) " " --> (40:1-40:2) "\t" +(45:3-45:8) "[()=>" --> (40:2-40:8) "[() =>" +(45:8-45:10) " {" --> (40:8-40:9) " " +(45:10-45:12) "}]" --> (40:9-40:14) "{}] =" +(45:12-45:21) "=function" --> (40:14-40:23) " function" +(45:21-45:25) " a()" --> (40:23-40:27) " a()" +(45:25-45:27) " {" --> (40:27-40:28) " " +(45:27-46:1) "};\n" --> (40:28-41:0) "{};" +(46:1-48:0) "}\n" --> (41:0-42:0) "\n}" +(48:0-48:4) "\nvar" --> (42:0-42:4) "\nvar" +(48:4-48:8) " x =" --> (42:4-42:8) " x =" +(48:8-48:17) " function" --> (42:8-42:17) " function" +(48:17-48:22) " fn()" --> (42:17-42:22) " fn()" +(48:22-48:24) " {" --> (42:22-42:23) " " +(48:24-49:0) "};" --> (42:23-43:0) "{};" +(49:0-49:4) "\nvar" --> (43:0-43:4) "\nvar" +(49:4-49:8) " x =" --> (43:4-43:8) " x =" +(49:8-49:20) " function ()" --> (43:8-43:19) " function()" +(49:20-49:22) " {" --> (43:19-43:20) " " +(49:22-51:0) "};\n" --> (43:20-44:0) "{};" +(51:0-51:1) "\n" --> (44:0-44:0) "" +(51:1-51:10) "(function" --> (44:0-44:10) "\n(function" +(51:10-51:15) " fn()" --> (44:10-44:15) " fn()" +(51:15-51:17) " {" --> (44:15-44:16) " " +(51:17-53:0) "});\n" --> (44:16-45:0) "{});" +(53:0-53:4) "\nvar" --> (45:0-45:4) "\nvar" +(53:4-53:8) " z =" --> (45:4-45:8) " z =" +(53:8-53:14) " () =>" --> (45:8-45:14) " () =>" +(53:14-53:16) " {" --> (45:14-45:15) " " +(53:16-54:0) "};" --> (45:15-46:0) "{};" +(54:0-54:4) "\nvar" --> (46:0-46:4) "\nvar" +(54:4-54:8) " z =" --> (46:4-46:8) " z =" +(54:8-54:13) " x =>" --> (46:8-46:15) " (x) =>" +(54:13-54:15) " {" --> (46:15-46:16) " " +(54:15-55:0) "};" --> (46:16-47:0) "{};" +(55:0-55:4) "\nvar" --> (47:0-47:4) "\nvar" +(55:4-55:8) " z =" --> (47:4-47:8) " z =" +(55:8-55:9) " " --> (47:8-47:9) " " +(55:9-55:15) "(x) =>" --> (47:9-47:15) "(x) =>" +(55:15-55:17) " {" --> (47:15-47:16) " " +(55:17-56:0) "};" --> (47:16-48:0) "{};" +(56:0-56:4) "\nvar" --> (48:0-48:4) "\nvar" +(56:4-56:8) " z =" --> (48:4-48:8) " z =" +(56:8-56:9) " " --> (48:8-48:9) " " +(56:9-56:12) "(x," --> (48:9-48:12) "(x," +(56:12-56:15) " y," --> (48:12-48:15) " y," +(56:15-56:21) " z) =>" --> (48:15-48:21) " z) =>" +(56:21-56:23) " {" --> (48:21-48:22) " " +(56:23-58:0) "};\n" --> (48:22-49:0) "{};" +(58:0-58:4) "\nx =" --> (49:0-49:4) "\nx =" +(58:4-58:15) " function()" --> (49:4-49:15) " function()" +(58:15-58:17) " {" --> (49:15-49:16) " " +(58:17-60:0) "};\n" --> (49:16-50:0) "{};" +(60:0-60:2) "\n(" --> (50:0-50:1) "\n" +(60:2-60:4) " {" --> (50:1-50:2) "(" +(60:4-60:8) " x =" --> (50:2-50:6) "{x =" +(60:8-60:19) " function()" --> (50:6-50:17) " function()" +(60:19-60:21) " {" --> (50:17-50:18) " " +(60:21-60:23) "} " --> (50:18-50:20) "{}" +(60:23-60:26) "} =" --> (50:20-50:23) "} =" +(60:26-60:28) " {" --> (50:23-50:24) " " +(60:28-61:1) "});\n" --> (50:24-51:1) "{});\n" @@ -631,22 +631,22 @@ Invalid Character `[` (84:1-89:0) "}\n\n/**\n * Keeps track of the current dispatcher.\n */" --> (60:2-61:2) "\t}\n\t" (89:0-89:4) "\nvar" --> (61:2-61:6) "\tvar" (89:4-89:29) " ReactCurrentDispatcher =" --> (61:6-61:31) " ReactCurrentDispatcher =" -(89:29-94:2) " {\n /**\n * @internal\n * @type {ReactComponent}\n */\n " --> (61:31-61:32) " " -(94:2-94:11) " current:" --> (61:32-61:41) "{current:" -(94:11-95:1) " null\n" --> (61:41-61:45) " nul" -(95:1-101:0) "};\n\n/**\n * Keeps track of the current batch's configuration such as how long an update\n * should suspend for if it needs to.\n */" --> (61:45-62:2) "l};\n\t" +(89:29-94:2) " {\n /**\n * @internal\n * @type {ReactComponent}\n */\n " --> (61:31-61:33) " {" +(94:2-94:11) " current:" --> (61:33-61:42) " current:" +(94:11-95:1) " null\n" --> (61:42-61:47) " null" +(95:1-101:0) "};\n\n/**\n * Keeps track of the current batch's configuration such as how long an update\n * should suspend for if it needs to.\n */" --> (61:47-62:2) " };\n\t" (101:0-101:4) "\nvar" --> (62:2-62:6) "\tvar" (101:4-101:30) " ReactCurrentBatchConfig =" --> (62:6-62:32) " ReactCurrentBatchConfig =" -(101:30-102:2) " {\n " --> (62:32-62:33) " " -(102:2-102:14) " transition:" --> (62:33-62:45) "{transition:" -(102:14-103:1) " 0\n" --> (62:45-62:46) " " -(103:1-111:0) "};\n\n/**\n * Keeps track of the current owner.\n *\n * The current owner is the component who should own any components that are\n * currently being constructed.\n */" --> (62:46-63:2) "0};\n\t" +(101:30-102:2) " {\n " --> (62:32-62:34) " {" +(102:2-102:14) " transition:" --> (62:34-62:46) " transition:" +(102:14-103:1) " 0\n" --> (62:46-62:48) " 0" +(103:1-111:0) "};\n\n/**\n * Keeps track of the current owner.\n *\n * The current owner is the component who should own any components that are\n * currently being constructed.\n */" --> (62:48-63:2) " };\n\t" (111:0-111:4) "\nvar" --> (63:2-63:6) "\tvar" (111:4-111:24) " ReactCurrentOwner =" --> (63:6-63:26) " ReactCurrentOwner =" -(111:24-116:2) " {\n /**\n * @internal\n * @type {ReactComponent}\n */\n " --> (63:26-63:27) " " -(116:2-116:11) " current:" --> (63:27-63:36) "{current:" -(116:11-117:1) " null\n" --> (63:36-63:40) " nul" -(117:1-119:0) "};\n" --> (63:40-64:2) "l};\n\t" +(111:24-116:2) " {\n /**\n * @internal\n * @type {ReactComponent}\n */\n " --> (63:26-63:28) " {" +(116:2-116:11) " current:" --> (63:28-63:37) " current:" +(116:11-117:1) " null\n" --> (63:37-63:42) " null" +(117:1-119:0) "};\n" --> (63:42-64:2) " };\n\t" (119:0-119:4) "\nvar" --> (64:2-64:6) "\tvar" (119:4-119:29) " ReactDebugCurrentFrame =" --> (64:6-64:31) " ReactDebugCurrentFrame =" (119:29-119:31) " {" --> (64:31-64:32) " " @@ -708,10 +708,10 @@ Invalid Character `[` (153:1-158:0) "}\n\n/**\n * Used by act() to track whether you're inside an act() scope.\n */" --> (89:2-90:2) "\t}\n\t" (158:0-158:4) "\nvar" --> (90:2-90:6) "\tvar" (158:4-158:27) " IsSomeRendererActing =" --> (90:6-90:29) " IsSomeRendererActing =" -(158:27-159:2) " {\n " --> (90:29-90:30) " " -(159:2-159:11) " current:" --> (90:30-90:39) "{current:" -(159:11-160:1) " false\n" --> (90:39-90:44) " fals" -(160:1-162:0) "};\n" --> (90:44-91:2) "e};\n\t" +(158:27-159:2) " {\n " --> (90:29-90:31) " {" +(159:2-159:11) " current:" --> (90:31-90:40) " current:" +(159:11-160:1) " false\n" --> (90:40-90:46) " false" +(160:1-162:0) "};\n" --> (90:46-91:2) " };\n\t" (162:0-162:4) "\nvar" --> (91:2-91:6) "\tvar" (162:4-162:27) " ReactSharedInternals =" --> (91:6-91:29) " ReactSharedInternals =" (162:27-163:26) " {\n ReactCurrentDispatcher:" --> (91:29-92:3) " {\n\t\t" @@ -1059,10 +1059,10 @@ Invalid Character `[` (399:26-399:36) "(Component" --> (187:26-187:36) "(Component" (399:36-399:47) ".prototype," --> (187:36-187:47) ".prototype," (399:47-399:59) " methodName," --> (187:47-187:59) " methodName," -(399:59-400:6) " {\n " --> (187:59-187:60) " " -(400:6-400:11) " get:" --> (187:60-187:65) "{get:" -(400:11-400:23) " function ()" --> (187:65-187:76) " function()" -(400:23-401:8) " {\n " --> (187:76-188:0) " {" +(399:59-400:6) " {\n " --> (187:59-187:61) " {" +(400:6-400:11) " get:" --> (187:61-187:66) " get:" +(400:11-400:23) " function ()" --> (187:66-187:77) " function()" +(400:23-401:8) " {\n " --> (187:77-188:0) " {" (401:8-401:13) " warn" --> (188:0-188:10) "\n\t\t\t\t\twarn" (401:13-401:76) "('%s(...) is deprecated in plain JavaScript React classes. %s'," --> (188:10-188:73) "(\"%s(...) is deprecated in plain JavaScript React classes. %s\"," (401:76-401:81) " info" --> (188:73-188:78) " info" @@ -1072,9 +1072,9 @@ Invalid Character `[` (401:93-403:8) ");\n\n " --> (188:90-189:0) ");" (403:8-403:15) " return" --> (189:0-189:12) "\n\t\t\t\t\treturn" (403:15-404:7) " undefined;\n " --> (189:12-190:4) " undefined;\n\t\t\t" -(404:7-405:5) "}\n " --> (190:4-190:5) "\t" -(405:5-405:6) "}" --> (190:5-190:7) "}}" -(405:6-406:3) ");\n " --> (190:7-191:3) ");\n\t\t" +(404:7-405:5) "}\n " --> (190:4-190:6) "\t}" +(405:5-405:6) "}" --> (190:6-190:8) " }" +(405:6-406:3) ");\n " --> (190:8-191:3) ");\n\t\t" (406:3-408:2) "};\n\n " --> (191:3-192:0) "\t};" (408:2-408:7) " for " --> (192:0-192:8) "\n\t\t\tfor " (408:7-408:11) "(var" --> (192:8-192:12) "(var" @@ -1145,10 +1145,10 @@ Invalid Character `[` (438:21-439:2) " {\n " --> (210:23-211:3) " {\n\t\t" (439:2-439:6) " var" --> (211:3-211:7) "\tvar" (439:6-439:18) " refObject =" --> (211:7-211:19) " refObject =" -(439:18-440:4) " {\n " --> (211:19-211:20) " " -(440:4-440:13) " current:" --> (211:20-211:29) "{current:" -(440:13-441:3) " null\n " --> (211:29-211:33) " nul" -(441:3-443:2) "};\n\n " --> (211:33-212:3) "l};\n\t\t" +(439:18-440:4) " {\n " --> (211:19-211:21) " {" +(440:4-440:13) " current:" --> (211:21-211:30) " current:" +(440:13-441:3) " null\n " --> (211:30-211:35) " null" +(441:3-443:2) "};\n\n " --> (211:35-212:3) " };\n\t\t" (443:2-444:4) " {\n " --> (212:3-213:0) "\t{" (444:4-444:11) " Object" --> (213:0-213:11) "\n\t\t\t\tObject" (444:11-444:16) ".seal" --> (213:11-213:16) ".seal" @@ -2741,10 +2741,10 @@ Invalid Character `[` (1228:9-1229:7) "}\n " --> (705:6-706:5) "\t}\n\t\t\t\t" (1229:7-1230:6) "},\n " --> (706:5-707:5) "\t},\n\t\t\t\t" (1230:6-1230:16) " Consumer:" --> (707:5-707:15) "\tConsumer:" -(1230:16-1231:8) " {\n " --> (707:15-707:16) " " -(1231:8-1231:13) " get:" --> (707:16-707:21) "{get:" -(1231:13-1231:25) " function ()" --> (707:21-707:32) " function()" -(1231:25-1232:10) " {\n " --> (707:32-708:0) " {" +(1230:16-1231:8) " {\n " --> (707:15-707:17) " {" +(1231:8-1231:13) " get:" --> (707:17-707:22) " get:" +(1231:13-1231:25) " function ()" --> (707:22-707:33) " function()" +(1231:25-1232:10) " {\n " --> (707:33-708:0) " {" (1232:10-1232:15) " if (" --> (708:0-708:11) "\n\t\t\t\t\t\tif (" (1232:15-1232:58) "!hasWarnedAboutUsingNestedContextConsumers)" --> (708:11-708:54) "!hasWarnedAboutUsingNestedContextConsumers)" (1232:58-1233:12) " {\n " --> (708:54-709:0) " {" @@ -2758,8 +2758,8 @@ Invalid Character `[` (1238:10-1238:17) " return" --> (712:0-712:13) "\n\t\t\t\t\t\treturn" (1238:17-1238:25) " context" --> (712:13-712:21) " context" (1238:25-1239:9) ".Consumer;\n " --> (712:21-713:5) ".Consumer;\n\t\t\t\t" -(1239:9-1240:7) "}\n " --> (713:5-713:6) "\t" -(1240:7-1241:6) "},\n " --> (713:6-714:5) "}},\n\t\t\t\t" +(1239:9-1240:7) "}\n " --> (713:5-713:7) "\t}" +(1240:7-1241:6) "},\n " --> (713:7-714:5) " },\n\t\t\t\t" (1241:6-1241:19) " displayName:" --> (714:5-714:18) "\tdisplayName:" (1241:19-1242:8) " {\n " --> (714:18-715:6) " {\n\t\t\t\t\t" (1242:8-1242:13) " get:" --> (715:6-715:11) "\tget:" @@ -2972,11 +2972,11 @@ Invalid Character `[` (1341:17-1341:32) ".defineProperty" --> (793:14-793:29) ".defineProperty" (1341:32-1341:42) "(lazyType," --> (793:29-793:39) "(lazyType," (1341:42-1341:58) " 'defaultProps'," --> (793:39-793:55) " \"defaultProps\"," -(1341:58-1342:12) " {\n " --> (793:55-793:56) " " -(1342:12-1342:24) " enumerable:" --> (793:56-793:68) "{enumerable:" -(1342:24-1343:11) " true\n " --> (793:68-793:72) " tru" -(1343:11-1343:12) "}" --> (793:72-793:74) "e}" -(1343:12-1344:9) ");\n " --> (793:74-794:6) ");\n\t\t\t\t\t" +(1341:58-1342:12) " {\n " --> (793:55-793:57) " {" +(1342:12-1342:24) " enumerable:" --> (793:57-793:69) " enumerable:" +(1342:24-1343:11) " true\n " --> (793:69-793:74) " true" +(1343:11-1343:12) "}" --> (793:74-793:76) " }" +(1343:12-1344:9) ");\n " --> (793:76-794:6) ");\n\t\t\t\t\t" (1344:9-1345:7) "}\n " --> (794:6-795:5) "\t}\n\t\t\t\t" (1345:7-1346:6) "},\n " --> (795:5-796:5) "\t},\n\t\t\t\t" (1346:6-1346:17) " propTypes:" --> (796:5-796:16) "\tpropTypes:" @@ -3004,11 +3004,11 @@ Invalid Character `[` (1357:17-1357:32) ".defineProperty" --> (804:14-804:29) ".defineProperty" (1357:32-1357:42) "(lazyType," --> (804:29-804:39) "(lazyType," (1357:42-1357:55) " 'propTypes'," --> (804:39-804:52) " \"propTypes\"," -(1357:55-1358:12) " {\n " --> (804:52-804:53) " " -(1358:12-1358:24) " enumerable:" --> (804:53-804:65) "{enumerable:" -(1358:24-1359:11) " true\n " --> (804:65-804:69) " tru" -(1359:11-1359:12) "}" --> (804:69-804:71) "e}" -(1359:12-1360:9) ");\n " --> (804:71-805:6) ");\n\t\t\t\t\t" +(1357:55-1358:12) " {\n " --> (804:52-804:54) " {" +(1358:12-1358:24) " enumerable:" --> (804:54-804:66) " enumerable:" +(1358:24-1359:11) " true\n " --> (804:66-804:71) " true" +(1359:11-1359:12) "}" --> (804:71-804:73) " }" +(1359:12-1360:9) ");\n " --> (804:73-805:6) ");\n\t\t\t\t\t" (1360:9-1361:7) "}\n " --> (805:6-806:5) "\t}\n\t\t\t\t" (1361:7-1362:5) "}\n " --> (806:5-807:4) "\t}\n\t\t\t" (1362:5-1362:6) "}" --> (807:4-807:6) "\t}" @@ -3636,71 +3636,71 @@ Invalid Character `[` (1607:21-1607:23) "({" --> (1007:19-1007:20) "(" (1607:23-1607:25) "}," --> (1007:20-1007:23) "{}," (1607:25-1607:32) " props," --> (1007:23-1007:30) " props," -(1607:32-1608:10) " {\n " --> (1007:30-1007:31) " " -(1608:10-1608:17) " value:" --> (1007:31-1007:38) "{value:" -(1608:17-1609:9) " prevLog\n " --> (1007:38-1007:45) " prevLo" -(1609:9-1609:10) "}" --> (1007:45-1007:47) "g}" -(1609:10-1610:8) "),\n " --> (1007:47-1008:6) "),\n\t\t\t\t\t" +(1607:32-1608:10) " {\n " --> (1007:30-1007:32) " {" +(1608:10-1608:17) " value:" --> (1007:32-1007:39) " value:" +(1608:17-1609:9) " prevLog\n " --> (1007:39-1007:47) " prevLog" +(1609:9-1609:10) "}" --> (1007:47-1007:49) " }" +(1609:10-1610:8) "),\n " --> (1007:49-1008:6) "),\n\t\t\t\t\t" (1610:8-1610:14) " info:" --> (1008:6-1008:12) "\tinfo:" (1610:14-1610:22) " _assign" --> (1008:12-1008:20) " _assign" (1610:22-1610:24) "({" --> (1008:20-1008:21) "(" (1610:24-1610:26) "}," --> (1008:21-1008:24) "{}," (1610:26-1610:33) " props," --> (1008:24-1008:31) " props," -(1610:33-1611:10) " {\n " --> (1008:31-1008:32) " " -(1611:10-1611:17) " value:" --> (1008:32-1008:39) "{value:" -(1611:17-1612:9) " prevInfo\n " --> (1008:39-1008:47) " prevInf" -(1612:9-1612:10) "}" --> (1008:47-1008:49) "o}" -(1612:10-1613:8) "),\n " --> (1008:49-1009:6) "),\n\t\t\t\t\t" +(1610:33-1611:10) " {\n " --> (1008:31-1008:33) " {" +(1611:10-1611:17) " value:" --> (1008:33-1008:40) " value:" +(1611:17-1612:9) " prevInfo\n " --> (1008:40-1008:49) " prevInfo" +(1612:9-1612:10) "}" --> (1008:49-1008:51) " }" +(1612:10-1613:8) "),\n " --> (1008:51-1009:6) "),\n\t\t\t\t\t" (1613:8-1613:14) " warn:" --> (1009:6-1009:12) "\twarn:" (1613:14-1613:22) " _assign" --> (1009:12-1009:20) " _assign" (1613:22-1613:24) "({" --> (1009:20-1009:21) "(" (1613:24-1613:26) "}," --> (1009:21-1009:24) "{}," (1613:26-1613:33) " props," --> (1009:24-1009:31) " props," -(1613:33-1614:10) " {\n " --> (1009:31-1009:32) " " -(1614:10-1614:17) " value:" --> (1009:32-1009:39) "{value:" -(1614:17-1615:9) " prevWarn\n " --> (1009:39-1009:47) " prevWar" -(1615:9-1615:10) "}" --> (1009:47-1009:49) "n}" -(1615:10-1616:8) "),\n " --> (1009:49-1010:6) "),\n\t\t\t\t\t" +(1613:33-1614:10) " {\n " --> (1009:31-1009:33) " {" +(1614:10-1614:17) " value:" --> (1009:33-1009:40) " value:" +(1614:17-1615:9) " prevWarn\n " --> (1009:40-1009:49) " prevWarn" +(1615:9-1615:10) "}" --> (1009:49-1009:51) " }" +(1615:10-1616:8) "),\n " --> (1009:51-1010:6) "),\n\t\t\t\t\t" (1616:8-1616:15) " error:" --> (1010:6-1010:13) "\terror:" (1616:15-1616:23) " _assign" --> (1010:13-1010:21) " _assign" (1616:23-1616:25) "({" --> (1010:21-1010:22) "(" (1616:25-1616:27) "}," --> (1010:22-1010:25) "{}," (1616:27-1616:34) " props," --> (1010:25-1010:32) " props," -(1616:34-1617:10) " {\n " --> (1010:32-1010:33) " " -(1617:10-1617:17) " value:" --> (1010:33-1010:40) "{value:" -(1617:17-1618:9) " prevError\n " --> (1010:40-1010:49) " prevErro" -(1618:9-1618:10) "}" --> (1010:49-1010:51) "r}" -(1618:10-1619:8) "),\n " --> (1010:51-1011:6) "),\n\t\t\t\t\t" +(1616:34-1617:10) " {\n " --> (1010:32-1010:34) " {" +(1617:10-1617:17) " value:" --> (1010:34-1010:41) " value:" +(1617:17-1618:9) " prevError\n " --> (1010:41-1010:51) " prevError" +(1618:9-1618:10) "}" --> (1010:51-1010:53) " }" +(1618:10-1619:8) "),\n " --> (1010:53-1011:6) "),\n\t\t\t\t\t" (1619:8-1619:15) " group:" --> (1011:6-1011:13) "\tgroup:" (1619:15-1619:23) " _assign" --> (1011:13-1011:21) " _assign" (1619:23-1619:25) "({" --> (1011:21-1011:22) "(" (1619:25-1619:27) "}," --> (1011:22-1011:25) "{}," (1619:27-1619:34) " props," --> (1011:25-1011:32) " props," -(1619:34-1620:10) " {\n " --> (1011:32-1011:33) " " -(1620:10-1620:17) " value:" --> (1011:33-1011:40) "{value:" -(1620:17-1621:9) " prevGroup\n " --> (1011:40-1011:49) " prevGrou" -(1621:9-1621:10) "}" --> (1011:49-1011:51) "p}" -(1621:10-1622:8) "),\n " --> (1011:51-1012:6) "),\n\t\t\t\t\t" +(1619:34-1620:10) " {\n " --> (1011:32-1011:34) " {" +(1620:10-1620:17) " value:" --> (1011:34-1011:41) " value:" +(1620:17-1621:9) " prevGroup\n " --> (1011:41-1011:51) " prevGroup" +(1621:9-1621:10) "}" --> (1011:51-1011:53) " }" +(1621:10-1622:8) "),\n " --> (1011:53-1012:6) "),\n\t\t\t\t\t" (1622:8-1622:24) " groupCollapsed:" --> (1012:6-1012:22) "\tgroupCollapsed:" (1622:24-1622:32) " _assign" --> (1012:22-1012:30) " _assign" (1622:32-1622:34) "({" --> (1012:30-1012:31) "(" (1622:34-1622:36) "}," --> (1012:31-1012:34) "{}," (1622:36-1622:43) " props," --> (1012:34-1012:41) " props," -(1622:43-1623:10) " {\n " --> (1012:41-1012:42) " " -(1623:10-1623:17) " value:" --> (1012:42-1012:49) "{value:" -(1623:17-1624:9) " prevGroupCollapsed\n " --> (1012:49-1012:67) " prevGroupCollapse" -(1624:9-1624:10) "}" --> (1012:67-1012:69) "d}" -(1624:10-1625:8) "),\n " --> (1012:69-1013:6) "),\n\t\t\t\t\t" +(1622:43-1623:10) " {\n " --> (1012:41-1012:43) " {" +(1623:10-1623:17) " value:" --> (1012:43-1012:50) " value:" +(1623:17-1624:9) " prevGroupCollapsed\n " --> (1012:50-1012:69) " prevGroupCollapsed" +(1624:9-1624:10) "}" --> (1012:69-1012:71) " }" +(1624:10-1625:8) "),\n " --> (1012:71-1013:6) "),\n\t\t\t\t\t" (1625:8-1625:18) " groupEnd:" --> (1013:6-1013:16) "\tgroupEnd:" (1625:18-1625:26) " _assign" --> (1013:16-1013:24) " _assign" (1625:26-1625:28) "({" --> (1013:24-1013:25) "(" (1625:28-1625:30) "}," --> (1013:25-1013:28) "{}," (1625:30-1625:37) " props," --> (1013:28-1013:35) " props," -(1625:37-1626:10) " {\n " --> (1013:35-1013:36) " " -(1626:10-1626:17) " value:" --> (1013:36-1013:43) "{value:" -(1626:17-1627:9) " prevGroupEnd\n " --> (1013:43-1013:55) " prevGroupEn" -(1627:9-1627:10) "}" --> (1013:55-1013:57) "d}" -(1627:10-1628:7) ")\n " --> (1013:57-1014:5) ")\n\t\t\t\t" +(1625:37-1626:10) " {\n " --> (1013:35-1013:37) " {" +(1626:10-1626:17) " value:" --> (1013:37-1013:44) " value:" +(1626:17-1627:9) " prevGroupEnd\n " --> (1013:44-1013:57) " prevGroupEnd" +(1627:9-1627:10) "}" --> (1013:57-1013:59) " }" +(1627:10-1628:7) ")\n " --> (1013:59-1014:5) ")\n\t\t\t\t" (1628:7-1628:8) "}" --> (1014:5-1014:7) "\t}" (1628:8-1630:5) ");\n /* eslint-enable react-internal/no-production-logging */\n " --> (1014:7-1015:4) ");\n\t\t\t" (1630:5-1632:4) "}\n\n " --> (1015:4-1016:0) "\t}" @@ -3846,16 +3846,16 @@ Invalid Character `[` (1702:28-1702:33) "(Fake" --> (1067:27-1067:32) "(Fake" (1702:33-1702:44) ".prototype," --> (1067:32-1067:43) ".prototype," (1702:44-1702:53) " 'props'," --> (1067:43-1067:52) " \"props\"," -(1702:53-1703:8) " {\n " --> (1067:52-1067:53) " " -(1703:8-1703:13) " set:" --> (1067:53-1067:58) "{set:" -(1703:13-1703:25) " function ()" --> (1067:58-1067:69) " function()" -(1703:25-1706:10) " {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n " --> (1067:69-1068:0) " {" +(1702:53-1703:8) " {\n " --> (1067:52-1067:54) " {" +(1703:8-1703:13) " set:" --> (1067:54-1067:59) " set:" +(1703:13-1703:25) " function ()" --> (1067:59-1067:70) " function()" +(1703:25-1706:10) " {\n // We use a throwing setter instead of frozen or non-writable props\n // because that won't throw in a non-strict mode function.\n " --> (1067:70-1068:0) " {" (1706:10-1706:16) " throw" --> (1068:0-1068:12) "\n\t\t\t\t\t\tthrow" (1706:16-1706:23) " Error(" --> (1068:12-1068:19) " Error(" (1706:23-1707:9) ");\n " --> (1068:19-1069:5) ");\n\t\t\t\t" -(1707:9-1708:7) "}\n " --> (1069:5-1069:6) "\t" -(1708:7-1708:8) "}" --> (1069:6-1069:8) "}}" -(1708:8-1710:6) ");\n\n " --> (1069:8-1070:0) ");" +(1707:9-1708:7) "}\n " --> (1069:5-1069:7) "\t}" +(1708:7-1708:8) "}" --> (1069:7-1069:9) " }" +(1708:8-1710:6) ");\n\n " --> (1069:9-1070:0) ");" (1710:6-1710:17) " if (typeof" --> (1070:0-1070:16) "\n\t\t\t\t\tif (typeof" (1710:17-1710:29) " Reflect ===" --> (1070:16-1070:28) " Reflect ===" (1710:29-1710:41) " 'object' &&" --> (1070:28-1070:40) " \"object\" &&" @@ -5075,11 +5075,11 @@ Invalid Character `[` (2262:15-2262:30) ".defineProperty" --> (1429:13-1429:28) ".defineProperty" (2262:30-2262:36) "(this," --> (1429:28-1429:34) "(this," (2262:36-2262:44) " 'type'," --> (1429:34-1429:42) " \"type\"," -(2262:44-2263:10) " {\n " --> (1429:42-1429:43) " " -(2263:10-2263:17) " value:" --> (1429:43-1429:50) "{value:" -(2263:17-2264:9) " type\n " --> (1429:50-1429:54) " typ" -(2264:9-2264:10) "}" --> (1429:54-1429:56) "e}" -(2264:10-2265:8) ");\n " --> (1429:56-1430:0) ");" +(2262:44-2263:10) " {\n " --> (1429:42-1429:44) " {" +(2263:10-2263:17) " value:" --> (1429:44-1429:51) " value:" +(2263:17-2264:9) " type\n " --> (1429:51-1429:56) " type" +(2264:9-2264:10) "}" --> (1429:56-1429:58) " }" +(2264:10-2265:8) ");\n " --> (1429:58-1430:0) ");" (2265:8-2265:15) " return" --> (1430:0-1430:13) "\n\t\t\t\t\t\treturn" (2265:15-2266:7) " type;\n " --> (1430:13-1431:5) " type;\n\t\t\t\t" (2266:7-2267:5) "}\n " --> (1431:5-1432:4) "\t}\n\t\t\t" diff --git a/tasks/coverage/minifier_test262.snap b/tasks/coverage/minifier_test262.snap index 87ac1b728ea05..6f4e52f07c749 100644 --- a/tasks/coverage/minifier_test262.snap +++ b/tasks/coverage/minifier_test262.snap @@ -2,6 +2,4 @@ commit: a1587416 minifier_test262 Summary: AST Parsed : 46406/46406 (100.00%) -Positive Passed: 46404/46406 (100.00%) -Expect to Parse: "staging/explicit-resource-management/call-dispose-methods.js" -Expect to Parse: "staging/explicit-resource-management/exception-handling.js" +Positive Passed: 46406/46406 (100.00%) diff --git a/tasks/minsize/minsize.snap b/tasks/minsize/minsize.snap index c6559d176f07d..19381e8ffdbff 100644 --- a/tasks/minsize/minsize.snap +++ b/tasks/minsize/minsize.snap @@ -1,26 +1,26 @@ Original | Minified | esbuild | Gzip | esbuild -72.14 kB | 24.32 kB | 23.70 kB | 8.78 kB | 8.54 kB | react.development.js +72.14 kB | 24.52 kB | 23.70 kB | 8.75 kB | 8.54 kB | react.development.js -173.90 kB | 61.92 kB | 59.82 kB | 19.66 kB | 19.33 kB | moment.js +173.90 kB | 62.60 kB | 59.82 kB | 19.71 kB | 19.33 kB | moment.js -287.63 kB | 93.13 kB | 90.07 kB | 32.48 kB | 31.95 kB | jquery.js +287.63 kB | 94.00 kB | 90.07 kB | 32.58 kB | 31.95 kB | jquery.js -342.15 kB | 123.60 kB | 118.14 kB | 45.79 kB | 44.37 kB | vue.js +342.15 kB | 124.12 kB | 118.14 kB | 45.28 kB | 44.37 kB | vue.js -544.10 kB | 75.13 kB | 72.48 kB | 26.47 kB | 26.20 kB | lodash.js +544.10 kB | 75.62 kB | 72.48 kB | 26.34 kB | 26.20 kB | lodash.js -555.77 kB | 274.87 kB | 270.13 kB | 91.58 kB | 90.80 kB | d3.js +555.77 kB | 278.56 kB | 270.13 kB | 92.03 kB | 90.80 kB | d3.js -977.19 kB | 458.04 kB | 458.89 kB | 124.56 kB | 126.71 kB | bundle.min.js +1.01 MB | 474.65 kB | 458.89 kB | 127.98 kB | 126.71 kB | bundle.min.js -1.25 MB | 674.62 kB | 646.76 kB | 166.81 kB | 163.73 kB | three.js +1.25 MB | 677.97 kB | 646.76 kB | 167.47 kB | 163.73 kB | three.js -2.14 MB | 745.86 kB | 724.14 kB | 182.68 kB | 181.07 kB | victory.js +2.14 MB | 749.89 kB | 724.14 kB | 183.30 kB | 181.07 kB | victory.js -3.20 MB | 1.03 MB | 1.01 MB | 334.72 kB | 331.56 kB | echarts.js +3.20 MB | 1.04 MB | 1.01 MB | 334.50 kB | 331.56 kB | echarts.js -6.69 MB | 2.43 MB | 2.31 MB | 504.05 kB | 488.28 kB | antd.js +6.69 MB | 2.43 MB | 2.31 MB | 505.16 kB | 488.28 kB | antd.js -10.82 MB | 3.52 MB | 3.49 MB | 910.42 kB | 915.50 kB | typescript.js +10.95 MB | 3.59 MB | 3.49 MB | 916.05 kB | 915.50 kB | typescript.js