diff --git a/crates/swc/tests/fixture/issues-7xxx/7984/input/.swcrc b/crates/swc/tests/fixture/issues-7xxx/7984/input/.swcrc new file mode 100644 index 000000000000..a35cd5524970 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7984/input/.swcrc @@ -0,0 +1,64 @@ +{ + "jsc": { + "parser": { + "syntax": "ecmascript", + "jsx": false + }, + "target": "es2022", + "loose": false, + "minify": { + "compress": { + "arguments": false, + "arrows": true, + "booleans": true, + "booleans_as_integers": false, + "collapse_vars": true, + "comparisons": true, + "computed_props": true, + "conditionals": true, + "dead_code": true, + "directives": true, + "drop_console": false, + "drop_debugger": true, + "evaluate": true, + "expression": false, + "hoist_funs": false, + "hoist_props": true, + "hoist_vars": false, + "if_return": true, + "join_vars": true, + "keep_classnames": false, + "keep_fargs": true, + "keep_fnames": false, + "keep_infinity": false, + "loops": true, + "negate_iife": true, + "properties": true, + "reduce_funcs": false, + "reduce_vars": false, + "side_effects": true, + "switches": true, + "typeofs": true, + "unsafe": false, + "unsafe_arrows": false, + "unsafe_comps": false, + "unsafe_Function": false, + "unsafe_math": false, + "unsafe_symbols": false, + "unsafe_methods": false, + "unsafe_proto": false, + "unsafe_regexp": false, + "unsafe_undefined": false, + "unused": true, + "const_to_let": true, + "pristine_globals": true + }, + "mangle": false + } + }, + "module": { + "type": "es6" + }, + "minify": false, + "isModule": true +} \ No newline at end of file diff --git a/crates/swc/tests/fixture/issues-7xxx/7984/input/1.js b/crates/swc/tests/fixture/issues-7xxx/7984/input/1.js new file mode 100644 index 000000000000..b8620aec7f21 --- /dev/null +++ b/crates/swc/tests/fixture/issues-7xxx/7984/input/1.js @@ -0,0 +1,17 @@ +getInitialProps = (code) => { + let statusCode, message; + + if (code) { + statusCode = code; + } + + switch (statusCode) { + case 404: + message = "404"; + break; + default: + message = "500"; + } + + return { statusCode, message }; +}; diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/7984/config.json b/crates/swc_ecma_minifier/tests/fixture/issues/7984/config.json new file mode 100644 index 000000000000..e24c2f770eb5 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/issues/7984/config.json @@ -0,0 +1,46 @@ +{ + "arguments": false, + "arrows": true, + "booleans": true, + "booleans_as_integers": false, + "collapse_vars": true, + "comparisons": true, + "computed_props": true, + "conditionals": true, + "dead_code": true, + "directives": true, + "drop_console": false, + "drop_debugger": true, + "evaluate": true, + "expression": false, + "hoist_funs": false, + "hoist_props": true, + "hoist_vars": false, + "if_return": true, + "join_vars": true, + "keep_classnames": false, + "keep_fargs": true, + "keep_fnames": false, + "keep_infinity": false, + "loops": true, + "negate_iife": true, + "properties": true, + "reduce_funcs": false, + "reduce_vars": false, + "side_effects": true, + "switches": true, + "typeofs": true, + "unsafe": false, + "unsafe_arrows": false, + "unsafe_comps": false, + "unsafe_Function": false, + "unsafe_math": false, + "unsafe_symbols": false, + "unsafe_methods": false, + "unsafe_proto": false, + "unsafe_regexp": false, + "unsafe_undefined": false, + "unused": true, + "const_to_let": true, + "pristine_globals": true +} diff --git a/crates/swc_ecma_minifier/tests/fixture/issues/7984/input.js b/crates/swc_ecma_minifier/tests/fixture/issues/7984/input.js new file mode 100644 index 000000000000..b8620aec7f21 --- /dev/null +++ b/crates/swc_ecma_minifier/tests/fixture/issues/7984/input.js @@ -0,0 +1,17 @@ +getInitialProps = (code) => { + let statusCode, message; + + if (code) { + statusCode = code; + } + + switch (statusCode) { + case 404: + message = "404"; + break; + default: + message = "500"; + } + + return { statusCode, message }; +};