diff --git a/cli/swc_util.rs b/cli/swc_util.rs index 9682554407..0d1d1ba089 100644 --- a/cli/swc_util.rs +++ b/cli/swc_util.rs @@ -32,9 +32,9 @@ use swc_ecma_visit::Visit; fn get_default_es_config() -> EsConfig { let mut config = EsConfig::default(); config.num_sep = true; - config.class_private_props = false; - config.class_private_methods = false; - config.class_props = false; + config.class_private_props = true; + config.class_private_methods = true; + config.class_props = true; config.export_default_from = true; config.export_namespace_from = true; config.dynamic_import = true; diff --git a/cli/tests/es_private_fields.js b/cli/tests/es_private_fields.js new file mode 100644 index 0000000000..b5f83e39c7 --- /dev/null +++ b/cli/tests/es_private_fields.js @@ -0,0 +1,15 @@ +class Foo { + #field = "field"; + + setValue(val) { + this.#field = val; + } + + getValue() { + return this.#field; + } +} + +const bar = new Foo(); +bar.setValue("PRIVATE"); +console.log(bar.getValue()); diff --git a/cli/tests/es_private_fields.js.out b/cli/tests/es_private_fields.js.out new file mode 100644 index 0000000000..be1970b053 --- /dev/null +++ b/cli/tests/es_private_fields.js.out @@ -0,0 +1 @@ +PRIVATE diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 0a50190d2a..6ab204082d 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1827,6 +1827,11 @@ itest!(fix_js_imports { output: "fix_js_imports.ts.out", }); +itest!(es_private_fields { + args: "run --quiet --reload es_private_fields.js", + output: "es_private_fields.js.out", +}); + itest!(proto_exploit { args: "run proto_exploit.js", output: "proto_exploit.js.out",