mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 09:38:16 +03:00
fix(es/codegen): Emit decorators on class methods (#4103)
This commit is contained in:
parent
133bfb43d3
commit
9b64a6960f
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -3039,6 +3039,7 @@ dependencies = [
|
||||
"swc_ecma_parser",
|
||||
"swc_ecma_transforms_base",
|
||||
"swc_ecma_transforms_optimization",
|
||||
"swc_ecma_transforms_proposal",
|
||||
"swc_ecma_transforms_react",
|
||||
"swc_ecma_transforms_typescript",
|
||||
"swc_ecma_utils",
|
||||
|
@ -65,6 +65,7 @@ swc_ecma_loader = { version = "0.29.0", path = "../swc_ecma_loader", features =
|
||||
"cache",
|
||||
] }
|
||||
swc_ecma_minifier = { version = "0.94.0", path = "../swc_ecma_minifier" }
|
||||
swc_ecma_transforms_proposal = { version = "0.91.0", path = "../swc_ecma_transforms_proposal" }
|
||||
swc_ecma_transforms_react = { version = "0.98.0", path = "../swc_ecma_transforms_react" }
|
||||
swc_ecma_transforms_typescript = { version = "0.101.0", path = "../swc_ecma_transforms_typescript" }
|
||||
swc_node_base = { version = "0.5.0", path = "../swc_node_base" }
|
||||
|
@ -18,7 +18,11 @@ use swc_common::{
|
||||
};
|
||||
use swc_ecma_ast::EsVersion;
|
||||
use swc_ecma_parser::{parse_file_as_module, Syntax, TsConfig};
|
||||
use swc_ecma_transforms_base::resolver::resolver_with_mark;
|
||||
use swc_ecma_transforms_base::{
|
||||
helpers::{inject_helpers, Helpers, HELPERS},
|
||||
resolver::resolver_with_mark,
|
||||
};
|
||||
use swc_ecma_transforms_proposal::decorators;
|
||||
use swc_ecma_transforms_react::react;
|
||||
use swc_ecma_transforms_typescript::strip;
|
||||
use swc_ecma_visit::FoldWith;
|
||||
@ -128,15 +132,22 @@ impl Load for Loader {
|
||||
});
|
||||
|
||||
let mark = Mark::fresh(Mark::root());
|
||||
let module = module
|
||||
.fold_with(&mut resolver_with_mark(mark))
|
||||
.fold_with(&mut strip(mark))
|
||||
.fold_with(&mut react::<SingleThreadedComments>(
|
||||
self.cm.clone(),
|
||||
None,
|
||||
Default::default(),
|
||||
top_level_mark,
|
||||
));
|
||||
let module = HELPERS.set(&Helpers::new(false), || {
|
||||
module
|
||||
.fold_with(&mut resolver_with_mark(mark))
|
||||
.fold_with(&mut decorators(decorators::Config {
|
||||
legacy: true,
|
||||
emit_metadata: Default::default(),
|
||||
}))
|
||||
.fold_with(&mut strip(mark))
|
||||
.fold_with(&mut react::<SingleThreadedComments>(
|
||||
self.cm.clone(),
|
||||
None,
|
||||
Default::default(),
|
||||
top_level_mark,
|
||||
))
|
||||
.fold_with(&mut inject_helpers())
|
||||
});
|
||||
|
||||
Ok(ModuleData {
|
||||
fm,
|
||||
|
@ -1223,6 +1223,10 @@ where
|
||||
|
||||
srcmap!(n, true);
|
||||
|
||||
for d in &n.function.decorators {
|
||||
emit!(d);
|
||||
}
|
||||
|
||||
self.emit_accessibility(n.accessibility)?;
|
||||
|
||||
if n.is_static {
|
||||
|
Loading…
Reference in New Issue
Block a user