Skip to content

Commit

Permalink
fix(parser): should walk parameters in class methods (#5813)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng authored Feb 29, 2024
1 parent d9c85e5 commit a55310c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,10 @@ impl<'parser> JavascriptParser<'parser> {
true,
method.function.params.iter().map(|p| Cow::Borrowed(&p.pat)),
|this| {
for param in &method.function.params {
this.walk_pattern(&param.pat);
}

// TODO: `hooks.body_value`;
if let Some(body) = &method.function.body {
this.walk_block_statement(body);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const foo = {
msg: 'hello'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { foo } from './foo'

it('should compile', () => {
class Foo {
foo(a = foo.msg) {
return a
}
}
expect(new Foo().foo()).toBe('hello')
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
entry: {
main: "./index.js",
},
};

1 comment on commit a55310c

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-02-29 dca4576) Current Change
10000_development-mode + exec 1.72 s ± 45 ms 1.75 s ± 26 ms +1.69 %
10000_development-mode_hmr + exec 929 ms ± 9.7 ms 901 ms ± 7.1 ms -3.06 %
10000_production-mode + exec 2.71 s ± 69 ms 2.64 s ± 22 ms -2.51 %
arco-pro_development-mode + exec 2.45 s ± 33 ms 2.46 s ± 45 ms +0.35 %
arco-pro_development-mode_hmr + exec 861 ms ± 9.3 ms 552 ms ± 2.7 ms -35.92 %
arco-pro_production-mode + exec 4.06 s ± 43 ms 4.07 s ± 45 ms +0.15 %
threejs_development-mode_10x + exec 1.9 s ± 13 ms 1.88 s ± 23 ms -0.94 %
threejs_development-mode_10x_hmr + exec 1.13 s ± 7.1 ms 1.12 s ± 9.7 ms -0.99 %
threejs_production-mode_10x + exec 5.66 s ± 49 ms 5.63 s ± 40 ms -0.66 %

Please sign in to comment.